Results 1 to 5 of 5

Thread: Like Operator

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    Like Operator

    Lets say I have a line like

    ************* ** 2345 Page 1 *****

    how do I say if I find the word page then msgbox "Page"
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Here is a simple way.
    VB Code:
    1. Dim sStr As String
    2.     sStr = "************* ** 2345 Page 1 *****"
    3.    
    4.     If InStr(1, sStr, "Page") > 0 Then
    5.         MsgBox "Page"
    6.     End If

  3. #3
    jim mcnamara
    Guest
    Not sure what you mean, especially the like operator part but try:
    Code:
    Dim tmp as String
    If instr(mystring," Page ") > 0 then
         tmp = mid(mystring,instr(mystring," Page ") )
        tmp = left(tmp,instr(tmp,"*")-1)
        msgbox tmp,vbOkOnly
    End if

  4. #4
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Jim : You are just being a little neater than i am. And i must agree never Hardcode the way i just hardcoded my code.

  5. #5
    WorkHorse
    Guest
    Doing the same sort of thing with the Like operator:
    VB Code:
    1. MyString = "************* ** 2345 Page 1 *****"
    2. MySearch = "Page"
    3. If MyString Like "*" & MySearch & "*" Then MsgBox MySearch
    The "*" wildcard character using Like means "any characters". Note that Like only tells you if the search string exists in the string. It doesn't tell you where the search string is located like InStr.

Posting Permissions

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



Click Here to Expand Forum to Full Width