Select Case with Wildcard (1 Viewer)

Randomblink

The Irreverent Reverend
Local time
Today, 06:06
Joined
Jul 23, 2001
Messages
279
Here is my code...

PHP:
    Select Case StreetType
        Case "*Arterial*"
            StrType = "Arterial"
        Case "*Parkway*"
            StrType = "Parkway"
        Case "*Expressway*"
            StrType = "*Expressway*"
    End Select

When I run the code, for an example, the value of StreetType is "Secondary Arterial"... I want the select case statement to find the word "Arterial" in that value and stop there and assign Arterial to the variable StrType...

Can someone tell me what I am doing wrong...???

Help me, Mr. Popeil...!

Thanks in advance...
 

Mile-O

Back once again...
Local time
Today, 12:06
Joined
Dec 10, 2002
Messages
11,316
You are looking at string values.

Try:

Code:
Select Case StreetType
    Case Like "*Arterial*"
        StrType = "Arterial"
    Case Like"*Parkway*"
        StrType = "Parkway"
    Case Like "*Expressway*"
        StrType = "*Expressway*"
End Select
 

Randomblink

The Irreverent Reverend
Local time
Today, 06:06
Joined
Jul 23, 2001
Messages
279
LIKE Ain't working...

I already tried LIKE...
I get the following error message...

Compile error:
Expected: = or <> or >< or >= or <= or =<
[OK] [HELP]

It just aint working... Oh, and I see an error that I should correct... The actual Select Case Statement is:

Code:
    Select Case StreetType
        Case "*Arterial*"
            StrType = "Arterial"
        Case "*Parkway*"
            StrType = "Parkway"
        Case "*Expressway*"
            StrType = "Expressway"
    End Select

(I had the StrType equaling a wildcard statement in my first message...)

If you can help... please do... thanks...
 

fuzzygeek

Energy Ebbing
Local time
Today, 12:06
Joined
Mar 28, 2003
Messages
989
IF

This appears to work try a variation of it.

Function tester()
Dim StrType As String
Dim StreetType As String
StreetType = "Secondary Parkway"

If StreetType Like "*Arterial*" Then

StrType = "Arterial"
ElseIf StreetType Like "*Parkway*" Then
StrType = "Parkway"
ElseIf StreetType Like "*Expressway*" Then
StrType = "Expressway"
Else
StrType = "UnKnown"
End If

Debug.Print StrType
End Function
 

cpod

Registered User.
Local time
Today, 06:06
Joined
Nov 7, 2001
Messages
107
You can't use the Like operator in a Select Case statement. Try this:

If InStr(strType, "Arterial") > 0 Then
strType = "Arterial"
ElseIf InStr(strType, "parkway") > 0 Then
strType = "Parkway"
ElseIf InStr(strType, "expressway") > 0 Then
strType = "Expressway"
End If
 

Users who are viewing this thread

Top Bottom