Results 1 to 4 of 4

Thread: I've got two questions..

  1. #1

    Thread Starter
    Lively Member Spie's Avatar
    Join Date
    Jul 2000
    Location
    On a very small coconut somewhere near Mars
    Posts
    126
    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

  2. #2
    Guest
    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

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  4. #4

    Thread Starter
    Lively Member Spie's Avatar
    Join Date
    Jul 2000
    Location
    On a very small coconut somewhere near Mars
    Posts
    126
    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
  •  



Click Here to Expand Forum to Full Width