Code Box #1
Private Sub cmdClose_Click()
Unload Me
End
End Sub
Private Sub cmdQuotes_Click()
frmManageQuotes.Show 1
End Sub
Private Sub Form_Load()
Dim currentQuote As Integer
Dim quote As typQuote
'error trap
On Error GoTo fileError
'center the form
Left = (Screen.Width - Width) / 2
Top = (Screen.Height - Height) / 2
'open the quotes file for reading
Open "c:\quotes.txt" For Random As #1 Len = Len(quote)
'calculate the number of the last quote in the file.
lastQuote = LOF(1) / Len(quote)
'calculate a random number between 1 and the number of quotes
Randomize
currentQuote = Int((lastQuote * Rnd) + 1)
'display the selected quote
Call readQuote(currentQuote, Me)
Close #1
procedureExit:
Exit Sub
fileError:
Message = "There is a critical file I/O error."
displayAlertMessage (Message)
Resume procedureExit
End Sub