Discussion Locked

VB problem

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

select case texttotal.text
case 40
label1.caption="sssxx"
case 50
label1.caption="sddxx"
case else
label1.caption="ssbhx"
end select in this vb prog. in the first time i ictivate the code, it skip the first line (case 40 ). it means suppose texttotal.text was 40, prog. should type in label1 as "sssxx". but at the first time I run the program it shows what is under case else statement. what is the error on this . Please help me.

5 replies

by streamlogic

Silvamsn,

Since you are comparing text in a textbox, you will need to make sure the 40 and 50 are also strings. I would wrap them in quotes ("") and make it case "40", case "50".

Hope this helps,
Curtis

Curtis Hughes
StreamLogic Inc.
http://www.StreamLogicInc.com

by rmcnaught

Try:

select case texttotal.text
case "40"
label1.caption="sssxx"
case "50"
label1.caption="sddxx"
case else
label1.caption="ssbhx"
end select

by clgan333

Try:

Use val build in function to convert it into numeric number.

Hope help...

select case val(texttotal.text)
case 40
label1.caption="sssxx"
case 50
label1.caption="sddxx"
case else
label1.caption="ssbhx"
end select

by truthcommission

Both of the answers here are correct. However if, for some reason, you didn't want to use the string value and wanted to use the integer value of the text. you could do a CINT to texttotal.text or maybe a CType(Texttotal.text,Integer), of course the data in texttotal would have to be an integer or you'll get an invalid cast exception

This discussion is closed to new replies.