hey guys, i have literaly started vb,net today, and need some help.
i have this code for a click button, which is a small part of my project, but i cant seem to get it to work, and this is crucial for the rest of my project. what i want to do is display a 1 in a label if a number entered in a textbox is found to be in a certain range
Dim label1 As Integer = 0 Dim textbox1 As Integer If textbox1 >=10 and textbox1 <=1 thenlabel1 = label1 + 1
End If
any help would be realy appreciated, thanks

begginers help
Rattlerr
If textbox1.text >= 10 and textbox1.text <=1 then
label1.text = "1"
End If
Well this is what i got but the value of the textbox can't be 10 or greater and at the same time be one or less than one. If you are trying to it it on the outside of the two values
If textbox1.text >= 10 or textbox1.text <=1 then
label1.text = "1"
End If
if you want it on the inside
If textbox1.text <= 10 and textbox1.text >=1 then
label1.text = "1"
End If
Alex Pizarro
your actually best converting the values to true Integer's before doing the comparison - your pretty much there in that example! Just do:
If Convert.ToInt32(textbox1.text) >= 10 or Convert.ToInt32(textbox1.text) <=1 then
label1.text = "1"
End If
however you need to be sure that the values entered are numeric otherwise doing a convert to an integer will result in a runtime exception being thrown
Jeph
Yeah, I forgot to add that, also wont interger.parse work
Eias Nabhan
indeed it would, but again you have that chance of the exception being thrown if the text is not numeric, in which case you have 2 options here to avoid this (validation)
the first one would be a better option:
Lakshmi N
textbox1 = Val(Text1)
This should work, it sets the value from the text box, default name Text1, to your variable.
Next, you need to show the value of label1 in your label.
Label1.caption = label1
CarlDemelo
Tomas L