Consulting

Results 1 to 3 of 3

Thread: Like command not finding comparing string

  1. #1
    VBAX Regular
    Joined
    Apr 2010
    Posts
    21
    Location

    Like command not finding comparing string

    I am using Attachmate Reflections which can run vba macros. My current project is to try to capture certain words as they scroll by on the screen during prescription filling sessions. Below is a typical portion of the screen as it scrolls by. In this case I am looking for the word GLAUCOMA.
    --------------------------------------
    Do you want to enter a Progress Note? No// NO
    Rx # 52423683 06/30/12
    MJIHUZXSS,JELUAHT D #7.5
    INSTILL 1 DROP IN BOTH EYES AT BEDTIME FOR GLAUCOMA
    LATANOPROST 0.005% OPH SOLN
    TIMMER,TIM WAGON, CHUCK
    # of Refills: 1
    Is this correct? YES// YES
    ---------------------------------------------------------------------
    Here is the portion of code that handles the above lines on the screen. I added a Msgbox to verify that each line was readable and INSTILL 1 DROP IN BOTH EYES AT BEDTIME FOR GLAUCOMA was read and displayed in the Msgbox as a String. strDISEASE is dimmed as a string variable

    [vba]
    .WaitForString "Do you want to enter a Progress Note?"
    .Transmit "NO" & CR

    GoTo SCCHECK

    SCCHECK:
    i = 1
    Do Until strReadline Like "*Is this correct?*" Or i > 100
    strReadline = ""

    strReadline = .ReadLine("00:00:01")

    If strReadline Like "Rx*" Then 'Grabs Rx number an puts it in Excel
    strRXGRAB = Mid(strReadline, 6, 8)
    End If

    'MsgBox strReadline, vbOKOnly

    If strReadline Like "*GLAUCOMA*" Then
    strDISEASE = "Yes"
    Else: strDISEASE = "No"
    End If

    i= i + 1
    Loop
    [/vba]

    Any thoughts on why "Like" would not work for the code below when it works perfectly for other parts of the code. The only difference in the other places I use "Like" is that I know how the entire string looks. Here the words before GLAUCOMA may be different in each prescription.

    Here is the portion of code to attempt to catch the word GLAUCOMA as it scrolls on the screen(same as above). I do not seen anything in MSDN that limits the Like operator.

    [vba]
    If strReadline Like "*GLAUCOMA*" Then
    strDISEASE = "Yes"
    Else: strDISEASE = "No"
    End If
    [/vba]

    Any suggestions would be appreciated. Thank you in advance.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Case differences? 'Like' is case sensitive

    [VBA]
    Option Explicit
    Sub test()
    Dim strReadline As String, strDISEASE As String
    strReadline = "INSTILL 1 DROP IN BOTH EYES AT BEDTIME FOR GLAUCOMA"
    If strReadline Like "*GLAUCOMA*" Then
    strDISEASE = "Yes"
    Else
    strDISEASE = "No"
    End If

    MsgBox strDISEASE

    If strReadline Like "*Glaucoma*" Then
    strDISEASE = "Yes"
    Else
    strDISEASE = "No"
    End If

    MsgBox strDISEASE
    End Sub
    [/VBA]

    Paul

  3. #3
    VBAX Regular
    Joined
    Apr 2010
    Posts
    21
    Location
    Paul, thanks for the response. I was unaware that Like was case sensitive, but that was not the problem. My logic was wrong. My Like statement worked, but since this reads line by line, the very next line after did not match so it changed always changed to No. I dropped the Else statement and worked with the alternative Null and it all worked fine.

    Thanks again

Posting Permissions

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