BobSki
BobSki

Reputation: 1552

storing values in a string to be used in a Select Case statement

Say I have a string that looks like this...

Dim Value as String
Value = "373, 273"

My goal is to be able to use the VALUE string in a case statement...

So something along the lines of

Dim Number as integer
Number = 273

Select Case Number

Case Value
   Msgbox "Value is 273"

Case else
  'do nothing
End select

When I run this case statement - it does not read the VALUE (273) therefore it just goes to case else.

How can I use VALUE in my select case statement so that it recognizes the value of it???

Upvotes: 0

Views: 104

Answers (1)

A Friend
A Friend

Reputation: 2750

Try this (untested):

Dim Number as Integer = 273
Dim Value = "373, 273"

Dim numAsString = CStr(Number)
If InStr(1, Value, numAsString)
    MsgBox("Value is " & numAsString)
End If

Upvotes: 1

Related Questions