Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select OR?

Status
Not open for further replies.

UnsolvedCoding

Technical User
Jul 20, 2011
424
US
Is there a way to do a select statement with an OR?

Example -

Select Case Left(CB_SINGLE_TextBox1, 1) <> "8" Or Left(IO_Single_TextBox1, 1) <> "8"




It has taken me a while to make sense of what I hear at work involving computers. There is much talk of bugs and questions about Raid.
Therefore I have come to the logical conclusion that the only way to have a properly functioning computer is to regularly spray it with Raid bug killer.
 
hi,
Code:
Select Case <expression>
   Case <expression list>
      <statements>
   Case Else
      <Statements>
End Select

You have and equation rather than an expression. The equation returns TRUE or FALSE. An expression resolves into a value. You need an expression.

Why not tell us what you're trying to accomplish.


Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Trying to determine the first digit of a number in a textbox. If its an 8 its the start of the default value, if its a 2 or a 3 its the start of a valid sequence.

Because the user form has two pages and three boxes on each page hold the same values, I have to isolate out the values of the boxes that are the same so I know what part of the user form has been updated so the rest of the program functions properly.

In a different way of looking at it, page one holds A, B, C, D, E and F and Page Two holds A, B, C, G, H and I.

 
Code:
Evaluate_This = Left(CB_SINGLE_TextBox1, 1) <> "8" Or Left(IO_Single_TextBox1, 1) <> "8"

Select Case Evaluate_This

Although it seems pointless to do it this way.

It's either TRUE or FALSE. So IF ... THEN ... (ELSE)... would seem to make more sense here.

 
Code:
Select Case Left(YourTextBox,1)
   Case "8"
      'do this if default
   Case "2", "3"
      'do this if "2" or "3"
   Case Else
      'do this if none of the above
End Select


Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
And once you know if it's an 8 or an "8" or a 2 or a "2" or a 3 or a "3" then what?
 
Very likely I will go with an if statement, however its written with a select and if I can adapt the select that would save time.

It has taken me a while to make sense of what I hear at work involving computers. There is much talk of bugs and questions about Raid.
Therefore I have come to the logical conclusion that the only way to have a properly functioning computer is to regularly spray it with Raid bug killer.
 
Select Case is very flexible, you can use conditions as in your example, both after Select Case and following Case(s). It's an alternative for nested If...Then structure.
You need to mind that (1) if the result of Select Case is logical True/False then the Case formula should also be logical, (2) only the code after the first match will be executed (or Case Else)and next it will jump to End Select.
In your example:
[pre]Select Case Left(CB_SINGLE_TextBox1, 1) <> "8" Or Left(IO_Single_TextBox1, 1) <> "8" 'True/False
Case <condition 1> ' True/False
...
Case <condition 2> ' True/False
...
Case ,Condition 3> ' True/False
...
...
....
End Select[/pre]

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top