General discussion

Locked

VB problem

By silvamsn ·
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.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by StreamLogic In reply to VB problem

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

Collapse -

by cmiller5400 In reply to VB problem

StreamLogic is correct. Wrap the 40 etc in quotes.

Collapse -

by rmcnaught In reply to VB problem

Try:

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

Collapse -

by clgan333 In reply to VB problem

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

Collapse -

by TruthCommission In reply to VB problem

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

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums