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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

runtime error '5' invalid procedure call or argument 1

Status
Not open for further replies.

petecef

Programmer
Joined
Oct 31, 2003
Messages
1
Location
US
trying to pick apart a line input string but get this error
if i use position it works, but when i '-1' from it i get the error. ive dimmed as ints and singles, still the same.
any ideas??




scoreFile = FreeFile
Open App.Path & "\scores.dat" For Input As #scoreFile
count = 0
Do Until EOF(scoreFile)
Dim position As Long
Dim space As Long
Line Input #scoreFile, golfdata
position = InStr(golfdata, ",")
space = InStr(golfdata, "")
error msg-- Lname(count) = Left$(golfdata, position - 1)
Fname(count) = Right$(golfdata, space + 5)
count = count + 1
Loop
 
What types have you declared scoreFile, golfdata, Lname and Fname, count as? "Space" is a VB function name - I wouldn't recommend using it as a variable name too.
Code:
Dim lngPosition As Long
Dim lngSpace As Long
Dim intScoreFile As Integer
Dim lngCount As Long
Dim strGolfData As String

intScoreFile = FreeFile
Open App.Path & "\scores.dat" For Input As #intScoreFile
lngCount = 0
Do Until EOF(intScoreFile)
  Line Input #intScoreFile, strGolfData
  lngPosition = InStr(strGolfData, ",")
  lngSpace = InStr(strGolfData, " ")
  If lngPosition > 0 Then  
    Lname(lngCount) = Left$(strGolfData, lngPosition - 1)
  Else
    Lname(lngCount) = ""","" not found " & lngCount
  End If
  If lngSpace > 0 Then
    Fname(lngCount) = Right$(strGolfData, lngSpace + 5)
  Else
    Fname(lngCount) = "Space not found" & lngCount
  lngCount = lngCount + 1
Loop
Close intScoreFile

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
Thanks for the star.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top