PDA

View Full Version : Like command not finding comparing string



Waubain
06-20-2012, 12:08 PM
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


.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


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.


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


Any suggestions would be appreciated. Thank you in advance.

Paul_Hossler
06-24-2012, 06:27 AM
Case differences? 'Like' is case sensitive


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


Paul

Waubain
06-25-2012, 07:24 PM
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