NewToVB
Computer
- May 4, 2007
- 5
Hi there,
I am new to VB and I was given a task to look at this little VB program which was written by other programmer. It was strange that I was able to open it and created an EXE on one machine before but now I keep getting this runtime error. Attach is the code.
Any help is appreciated
Private Sub LoadArrayPolls()
' Load the Document Types and related symbols into an array and then populate a combo box
Dim PollStr As String
Dim Indexcount As Integer ' Counter to load the ListBox
Dim Arraycount As Integer ' Counter to load the ListBox
Dim NumberPollFile As Integer ' File number assigned
Dim PollNo As Integer
Dim NumberofRaces As Integer ' Number of Races in this Polling Station
Dim RaceNo1 As Integer
Dim RaceNo2 As Integer
Dim RaceNo3 As Integer
Dim RaceNo4 As Integer
Dim RaceNo5 As Integer
'Dim RaceNo6 As Integer
' Retrieve a free file number
NumberPollFile = FreeFile
' Assemble the string for the Poll station information file which includes the subdirectory paths
PollStr = ELECTIONDRIVE & ELECTION2001DIR & DATADIR & CONFIGURATIONDIR & POLLSTATIONFILE
' Open the Polling Station text file containing the races to read into the Poll array
Open PollStr For Input Access Read Shared As #NumberPollFile
' Initialize Array Counter
Arraycount = 0
Do Until EOF(NumberPollFile)
' Read the Poll Number and the Races from the Poll file
Input #NumberPollFile, PollNo, NumberofRaces, RaceNo1, RaceNo2, RaceNo3, RaceNo4, RaceNo5
' Store the information into the Poll array
' Store Poll number in array
ArrayPolls(Arraycount, 0) = PollNo
' Store Number of Races for this Polling Station in array
ArrayPolls(Arraycount, 1) = NumberofRaces
' Store Race1 number in array
ArrayPolls(Arraycount, 2) = RaceNo1
' Store Race2 number in array
ArrayPolls(Arraycount, 3) = RaceNo2
' Store Race3 number in array
ArrayPolls(Arraycount, 4) = RaceNo3
' Store Race4 number in array
ArrayPolls(Arraycount, 5) = RaceNo4
' Store Race5 number in array
ArrayPolls(Arraycount, 6) = RaceNo5
' Store Race6 number in array
'ArrayPolls(Arraycount, 7) = RaceNo6
' Increment the counter
Arraycount = Arraycount + 1
Loop
' Close the file
Close #NumberPollFile
For Indexcount = 0 To (Arraycount - 1)
frmPoll_Station.lstPollNumber.AddItem ArrayPolls(Indexcount, 0)
Next Indexcount
If Arraycount > 0 Then
frmPoll_Station.lstPollNumber.Selected(0) = True
End If
End Sub
I am new to VB and I was given a task to look at this little VB program which was written by other programmer. It was strange that I was able to open it and created an EXE on one machine before but now I keep getting this runtime error. Attach is the code.
Any help is appreciated
Private Sub LoadArrayPolls()
' Load the Document Types and related symbols into an array and then populate a combo box
Dim PollStr As String
Dim Indexcount As Integer ' Counter to load the ListBox
Dim Arraycount As Integer ' Counter to load the ListBox
Dim NumberPollFile As Integer ' File number assigned
Dim PollNo As Integer
Dim NumberofRaces As Integer ' Number of Races in this Polling Station
Dim RaceNo1 As Integer
Dim RaceNo2 As Integer
Dim RaceNo3 As Integer
Dim RaceNo4 As Integer
Dim RaceNo5 As Integer
'Dim RaceNo6 As Integer
' Retrieve a free file number
NumberPollFile = FreeFile
' Assemble the string for the Poll station information file which includes the subdirectory paths
PollStr = ELECTIONDRIVE & ELECTION2001DIR & DATADIR & CONFIGURATIONDIR & POLLSTATIONFILE
' Open the Polling Station text file containing the races to read into the Poll array
Open PollStr For Input Access Read Shared As #NumberPollFile
' Initialize Array Counter
Arraycount = 0
Do Until EOF(NumberPollFile)
' Read the Poll Number and the Races from the Poll file
Input #NumberPollFile, PollNo, NumberofRaces, RaceNo1, RaceNo2, RaceNo3, RaceNo4, RaceNo5
' Store the information into the Poll array
' Store Poll number in array
ArrayPolls(Arraycount, 0) = PollNo
' Store Number of Races for this Polling Station in array
ArrayPolls(Arraycount, 1) = NumberofRaces
' Store Race1 number in array
ArrayPolls(Arraycount, 2) = RaceNo1
' Store Race2 number in array
ArrayPolls(Arraycount, 3) = RaceNo2
' Store Race3 number in array
ArrayPolls(Arraycount, 4) = RaceNo3
' Store Race4 number in array
ArrayPolls(Arraycount, 5) = RaceNo4
' Store Race5 number in array
ArrayPolls(Arraycount, 6) = RaceNo5
' Store Race6 number in array
'ArrayPolls(Arraycount, 7) = RaceNo6
' Increment the counter
Arraycount = Arraycount + 1
Loop
' Close the file
Close #NumberPollFile
For Indexcount = 0 To (Arraycount - 1)
frmPoll_Station.lstPollNumber.AddItem ArrayPolls(Indexcount, 0)
Next Indexcount
If Arraycount > 0 Then
frmPoll_Station.lstPollNumber.Selected(0) = True
End If
End Sub