Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Infamous loop need EOF help

Status
Not open for further replies.

blkblts

IS-IT--Management
Joined
Jul 16, 2001
Messages
16
Location
US
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 &quot;IMPORTANT: &quot; + Trim(SF0.Subject) + &quot; is NOT a Subject in the list. Please try again!&quot;, 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
 
Thats because there is no EOF property for the FILE object and you never did an ON Error GOTO 0 so that the error would show.
Do while NOT objFile.AtEndOfStream
 
Thank you so much the AtEndofstream worked perfectly.

Kim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top