I am new to vbscript... I have the following code:
Sub CheckForVIPMembers
Dim objFS ' File System Object
Dim objFile ' File object
Dim strFile_MemberID ' buffer to hold member ID from file
Dim strSF_MemberID ' buffer to hold member ID from Service Form
Dim intcounter
On Error Resume Next
Set objFS = CreateObject("Scripting.FileSystemObject"
If objFS is nothing Then
Exit Sub
End If
Set objFile = objFS.OpenTextFile("C:\VIPMbrs.txt", ForReading)
If objFile is nothing Then
Set objFS = nothing
Exit Sub
End If
Call Show ("Checking for VIP Members", "", ""
strSF_MemberID = SF0.Subject
Do while NOT objFile.EOF
strFile_MemberID = objFile.ReadLine
If Trim(strFile_MemberID) = Trim(strSF_MemberID) then
msgbox "counter" & intcounter
intcounter = intcounter + 1
'Exit Do
End IF
Loop
msgbox intcounter
If intcounter <> 1 then
MsgBox "IMPORTANT: " + Trim(SF0.Subject) + " is NOT a Subject in the list. Please try again!", vbCritical
End If
objFile.Close
set objFile = nothing
set objFS = nothing
End Sub
What I ultimately want is to read through all the lines of the vipmbrs.txt and compare to a choice chosen in a dropdown box on my form (sfo.subject). If the user keyed something in the dropdown box (sfo.subject) that is not in the vipmbrs.txt I want a msgbox to tell the user it is not in the list. Thanks What I get now is a loop that never ends. I can't get it to see the EOF.
Thanks
Kim
Sub CheckForVIPMembers
Dim objFS ' File System Object
Dim objFile ' File object
Dim strFile_MemberID ' buffer to hold member ID from file
Dim strSF_MemberID ' buffer to hold member ID from Service Form
Dim intcounter
On Error Resume Next
Set objFS = CreateObject("Scripting.FileSystemObject"
If objFS is nothing Then
Exit Sub
End If
Set objFile = objFS.OpenTextFile("C:\VIPMbrs.txt", ForReading)
If objFile is nothing Then
Set objFS = nothing
Exit Sub
End If
Call Show ("Checking for VIP Members", "", ""
strSF_MemberID = SF0.Subject
Do while NOT objFile.EOF
strFile_MemberID = objFile.ReadLine
If Trim(strFile_MemberID) = Trim(strSF_MemberID) then
msgbox "counter" & intcounter
intcounter = intcounter + 1
'Exit Do
End IF
Loop
msgbox intcounter
If intcounter <> 1 then
MsgBox "IMPORTANT: " + Trim(SF0.Subject) + " is NOT a Subject in the list. Please try again!", vbCritical
End If
objFile.Close
set objFile = nothing
set objFS = nothing
End Sub
What I ultimately want is to read through all the lines of the vipmbrs.txt and compare to a choice chosen in a dropdown box on my form (sfo.subject). If the user keyed something in the dropdown box (sfo.subject) that is not in the vipmbrs.txt I want a msgbox to tell the user it is not in the list. Thanks What I get now is a loop that never ends. I can't get it to see the EOF.
Thanks
Kim