Lanc1988 Posted December 7, 2004 Posted December 7, 2004 I have a label and I would like to know the code that would say something like: If label1.text is < 99 and > 201 Then label2.text = "1" End If Quote
Mothra Posted December 7, 2004 Posted December 7, 2004 All you have to do is convert the text in the textbox to a number and then compare it like you did. Quote Being smarter than you look is always better than looking smarter than you are.
Lanc1988 Posted December 7, 2004 Author Posted December 7, 2004 well I had tried something like that but it wasn't displaying the right number in the label.. could you post a short example? Quote
*Experts* DiverDan Posted December 7, 2004 *Experts* Posted December 7, 2004 something like: If CInt(Label1.Text) < 99 And CInt(Label1.Text) > 201 Then Label2.Text = "2" End If ...CInt converts the text value to an integer value ...CDbl converts to a Double ...CByte to a Byte etc. However, you might want to preceed this with a If Char.IsNumber(Label1.Text) in case the text is not numeric, thus preventing a large error message. If Char.IsNumber(Label1.Text) Then If CInt(Label1.Text) < 99 And CInt(Label1.Text) > 201 Then Label2.Text = "2" End If End If Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
penfold69 Posted December 7, 2004 Posted December 7, 2004 something like: If CInt(Label1.Text) < 99 And CInt(Label1.Text) > 201 Then Erm, just a quickie, but how can a number be <99 AND >201 ? Exactly what criteria are you trying to achieve? You're probably looking to use an OR, not an AND (for numbers <99 OR numbers >201) However, you might actually be wanting to use an AND (for numbers >99 AND <201) So, can you be a little more specific, and we can help you more! B. Quote
Lanc1988 Posted December 8, 2004 Author Posted December 8, 2004 is there a way to use: Select Case 'something Case Is < 0 and > 200 'something = "1" Case Is < 200 and > 300 'something = "2" End Case Could I somehow use that? Because I have used it before to convert just single numbers to other numbers.. (Example, if a 5 is entered in the textbox, i had it convert to 412) Quote
Lanc1988 Posted December 8, 2004 Author Posted December 8, 2004 wait.. i just realized.. am i using the < and > wrong? < means less than and > means greater than, right? Quote
Lanc1988 Posted December 8, 2004 Author Posted December 8, 2004 Thanks, DiverDan, it works perfectly for what i needed to do. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.