|
-
Jan 31st, 2001, 05:51 PM
#1
Thread Starter
Lively Member
I've got two questions which (I hope) will be simple.
1) I made a program that loads a highscore file when it starts. The only thing is, If the highscore file isnt there, it give me a runtime error. Can I make it either create the file or have a message saying "you must have the highscore file"?
2) Can I put some kind of code into the exit button at the top right of the form?
Thanks,
Spie
-
Jan 31st, 2001, 06:07 PM
#2
1) Use the Dir() function to check if it exists.
Code:
Private Sub Form_Load()
If Dir("HighScoreFile.txt") <> "" Then
'Hi score file exists
Else
'Hi score file does not exist so display a MsgBox
MsgBox "Make sure you have a high score table"
End If
End Sub
2) The QueryUnload event
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'If the X is pressed then
If UnloadMode = 0 Then
MsgBox "Quitting..."
End If
End Sub
-
Jan 31st, 2001, 06:09 PM
#3
transcendental analytic
Code:
'in declarations
private Type Highscores
Names(9) as string * 20
SCore(9) as long
End Type
private hs as highscores
'To save
Open file for binary as 1
put#1,,hs
Close 1
'To load
Open file for binary as 1
get#1,,hs
Close 1
This way it won't show you any errors, it creates a file whenever there's not and reads empty scores in such case.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 31st, 2001, 08:16 PM
#4
Thread Starter
Lively Member
Ok, I'll try that. Thanks
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
|