User Input Display Problems

Displaying user input.

Page 1 of 1

3 Replies - 1265 Views - Last Post: 10 March 2009 - 12:30 PM Rate Topic: -----

#1 MrCracker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 18-October 07

User Input Display Problems

Post icon  Posted 10 March 2009 - 06:30 AM

This is the code:

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
		Dim decX As Integer
		Dim decMult As Integer
		Dim decTotal As Integer

		If IsNumeric(txtx.Text) Then
			decX = txtx.Text
			For decMult = 1 To 9
				decTotal = decX * decMult
				lblDisplay.Text = lblDisplay.Text & txtx.Text & " * " & decMult & " = " _
								  & decTotal & ControlChars.NewLine
			Next decMult

		Else
			MessageBox.Show("x must be numerical.", "Multiplication Table", _
			MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)

		End If
	End Sub


In the part where the user input and multiplication is displayed on the screen (lblDisplay.Text), how come it only displays once if I exclude the lblDisplay.Text. It makes no sense to add it because im putting down what the user inputed then the * followed by 1-9, and finally = answer. Makes no sense to have lblDisplay.Text there. Can someone please explain to me?

Is This A Good Question/Topic? 0
  • +

Replies To: User Input Display Problems

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9585
  • View blog
  • Posts: 36,323
  • Joined: 12-June 08

Re: User Input Display Problems

Posted 10 March 2009 - 08:05 AM

Could you rephrase that? I don't know what you are asking.

What is the intended results?
What is the actual results?
Was This Post Helpful? 0
  • +
  • -

#3 MrWobbles  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 31
  • View blog
  • Posts: 328
  • Joined: 11-April 08

Re: User Input Display Problems

Posted 10 March 2009 - 09:15 AM

If I understand your question at all, you are asking why you have to say:

labelDisplay.text = labelDisplay.text & string



instead of just saying:

labelDisplay.text = string



If I am right in this, then if you use it the second way you are telling the computer to replace whatever is already in labelDisplay.text with the new value. By doing it the first way you tell the computer to include the text that is already in the label, so it stays. If you really don't like how it looks you could try this instead:

labelDisplay.text &= string



that is like saying it the first way.. only shorter.
Was This Post Helpful? 1
  • +
  • -

#4 MrCracker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 18-October 07

Re: User Input Display Problems

Posted 10 March 2009 - 12:30 PM

View PostMrWobbles, on 10 Mar, 2009 - 08:15 AM, said:

If I understand your question at all, you are asking why you have to say:

labelDisplay.text = labelDisplay.text & string



instead of just saying:

labelDisplay.text = string



If I am right in this, then if you use it the second way you are telling the computer to replace whatever is already in labelDisplay.text with the new value. By doing it the first way you tell the computer to include the text that is already in the label, so it stays. If you really don't like how it looks you could try this instead:

labelDisplay.text &= string



that is like saying it the first way.. only shorter.


Haha, yah that's what I meant.

I understand now, thank you :-).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1