|
-
May 31st, 2002, 09:52 PM
#1
Thread Starter
Lively Member
[RESOLVED] VB Error
hey all,
can anyone tell me what is wrong with this??
VB Code:
FileName = App.Path & "\Scores\High Score.cam"
'get high scores from file
Open FileName For Input As 1
Do Until EOF(1)
Line Input #1, HScore.Name
Line Input #1, HScore.Score
Loop
Close #1
in a code module, i have a Public Type which is where the HScore.Name and HScore.Score came from. when i try to run the program, it comes up with a mismatch error and when i click debug, it highlights the .Score part of HScore.Score
thanks
Last edited by DJ P@CkMaN; May 31st, 2002 at 10:33 PM.
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
May 31st, 2002, 09:58 PM
#2
Hyperactive Member
If Score is numeric you may need to convert it to a numeric value.
FileName = App.Path & "\Scores\High Score.cam"
'get high scores from file
Open FileName For Input As 1
Do Until EOF(1)
Line Input #1, HScore.Name
Line Input #1, Score$
HScore.Score = clng(Score$)
Loop
Close #1
-
May 31st, 2002, 10:01 PM
#3
Thread Starter
Lively Member
that sounds right because in the type, its
Score As Integer
thanx for the help
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
May 31st, 2002, 10:03 PM
#4
Thread Starter
Lively Member
i get an Overflow error. it highlights
VB Code:
HScore.Score = CLng(Score$)
any ideas??
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
May 31st, 2002, 10:20 PM
#5
Hyperactive Member
Why are you using Line Input?
Line Input reads the entire line in the file until it encounters a CR.
If the file contains this data, for instance,
Johnny, 1345
Billy, 7890
Line input would read the whole line - 'Johnny, 1345' into the first variable.
Input would only read 'Johnny'
-
May 31st, 2002, 10:25 PM
#6
Thread Starter
Lively Member
the file is
so i do line input, and line 1 goes into HScore.Name and the score goes into HScore.Score
it works fine if i use plain strings instead of a public type, so i tried
VB Code:
Open FileName For Input As 1
Do Until EOF(1)
Line Input #1, strName
Line Input 1, intScore
Loop
Close #1
HScore.Name = strName
HScore.Score = intScore
but i get an overflow error with that
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
May 31st, 2002, 10:29 PM
#7
Hyperactive Member
The overflow error on an integer data type is usually caused by being assigned a value greater than 32767.
Are there any scores greater than that? If so, try using a Long Integer.
HTH
-
May 31st, 2002, 10:31 PM
#8
Thread Starter
Lively Member
the highest possible score is 120, but i will try changing it to Long and see if that makes a diff
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
May 31st, 2002, 10:32 PM
#9
Thread Starter
Lively Member
weird.. Long works perfectly.. oh well, thanx heaps for your help
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
May 31st, 2002, 10:41 PM
#10
You were trying to assign a CLng (a LONG conversion) to
HScore.Score (prolly Dimmed an Integer).... So it would make
sense that HScore.Score should be Dimensioned as a Long.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|