Lope
10-02-2001, 08:14 AM
How does one use an AND or an OR in a Case statement? I get an error when I try to use: Case text1.text >= 300 AND text1.text < 400
Select Case StatementLope 10-02-2001, 08:14 AM How does one use an AND or an OR in a Case statement? I get an error when I try to use: Case text1.text >= 300 AND text1.text < 400 jcd 10-02-2001, 08:33 AM You dont want to use if and elseif statements?? regards jcd Yoda 10-02-2001, 08:36 AM For an OR you can use comma as delimiters : <font color=blue>Select Case</font color=blue> TxtField <font color=blue>Case</font color=blue> "One", "Three", "Five" ... <font color=blue>Case</font color=blue> "Two", "Six" ... <font color=blue>Case</font color=blue> "Four" ... <font color=blue>End Select</font color=blue> <font color=green>Do or do not There is no try</font color=green> Lope 10-02-2001, 08:40 AM This is something we covered in class and not even the teacher knew if AND could be used in a Case Statement; hence, the reason for the post. Thanks! rcg 10-02-2001, 08:41 AM This works. Select Case Text1.Text Case 300 To 399 MsgBox "In Range" Case Else MsgBox "Out of Range" End Select Lope 10-02-2001, 08:43 AM Thank you. I will try this and see if it works on my example. Do you know how to use AND in this same scenario? rcg 10-02-2001, 08:44 AM I found this in a web site. See if it helps. ' Initialize variable Dim Number As Integer Number = 8 Select Case Number ' Evaluate Number. Case 1 To 5 ' Number between 1 and 5. Msgbox "Between 1 and 5" Case 6, 7, 8 ' Number between 6 and 8. Msgbox "Between 6 and 8" Case Is > 8 And Number < 11 ' Number is 9 or 10. Msgbox "Greater than 8" Case Else ' Other values. Msgbox "Not between 1 and 10" End Select orufet 10-02-2001, 08:45 AM Well, you could put an If statment inside the select statment.. eg. <pre>Select Case MyVar Case 1 to 10 If My Var < 5 Then MsgBox "" End If End Select </pre> Don't know if that helps or not, though "I do not agree with a word you say, but I will defend to the death your right to say it" - Voltaire rcg 10-02-2001, 08:48 AM Sorry about the no indentations. How do I paste something in with the correct spacing? Lope 10-02-2001, 08:48 AM Thanks a lot! This worked. I really appreciate your help. Good day! :-) Mill 10-02-2001, 08:50 AM Look at the FAQ (http://www.visualbasicforum.com/bbs/faq_english.php?Cat=#html) and use the [.pre] tag without the period. "The LORD is my strength and my shield" - Psalms 28:7 Banjo 10-02-2001, 08:51 AM Use (with periods removed): [.pre]Code Here[/.pre] Lope 10-02-2001, 08:51 AM Thank you! This is an interesting way of doing it. Thinking outside of the box. . . I like it. :-) |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum