Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select Case - Case Like? (WIN 2000 Acc 97)

    I really miss Mr. Searchy! I even clicked subject/ascending order and scrolled til I got to the "S"s.
    Read all the posts re: Select, but I couldn't find a similar post.

    I want my Select statement to use 'Like' :

    Select Case myText
    Case 1 "Hello"
    code
    Case 2 Like "Good" '(I also tried: Like *"Good", and just *"Good")
    code
    etc...
    End Select

    What is the proper syntax to use the Like operator in a case statement?

    Thank you,
    Michael Abrams

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Select Case - Case Like? (WIN 2000 Acc 97)

    Sorry, the on-line documentation explicitly states that Like can't be used in a Case statement. You will have to use If ... Then:

    If myText = "Hello" Then
    ' something
    ElseIf myText Like "*Good" Then ' note that the wild card is within the quotes
    ' something else
    ElseIf ...
    ...
    End If

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Select Case - Case Like? (WIN 2000 Acc 97)

    Thanks Hans!
    That'll teach me to 'click' the green highlighted words next time (even if I know their definition). <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

    I appreciate your help Hans.

    Thank you,
    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •