Overclock.net banner

VB question

361 Views 0 Replies 1 Participant Last post by  a1i1d1e1n1
MODULE

Public Sub validnumber(ByVal word As String, ByRef number As Single, ByVal min As Integer, ByVal max As Integer)

Dim entry As String

Do
entry = InputBox("Please enter the " & word, word & " entry")
number = Val(entry) 'converts the user's entry to a number

If number < min Or number > max Or Int(number) <> number Or Not IsNumeric(entry) Then
MsgBox "Please enter a whole number between " & min & " and " & max
End If
Loop Until number >= min And number <= max And Int(number) = number And IsNumeric(entry)

End Sub

Program

' Date: 26/11/09
' Description: This program will allow the user to enter the number of accidents
' For predefined area's in scotland. Once the data has been entered the program will
' Find the biggest number of accidents and then display the area's in which they happend

Option Explicit
Private Sub CmdStart_Click()
Dim area(6) As String
Dim Accident(6) As Single
Dim Biggest As Integer
Dim Counter As Integer
Dim numlist As Integer

numlist = 5

For Counter = 0 To numlist
Call GetandDisplayAreasAccidents(area(), Accident(), Counter)
Next
Call BiggestArea(area(), Accident(), Biggest, numlist)
Call Search(Accident(), Biggest, Counter, area(), numlist)

End Sub

Public Sub GetandDisplayAreasAccidents(ByRef area() As String, ByRef Accident() As Single, ByVal Counter As Integer)

area(0) = "Tayside"
area(1) = "Grampian"
area(2) = "Highland"
area(3) = "Borders"
area(4) = "Strathclyde"
area(5) = "Lothian"

Call validnumber("The number of Accidents in " & area(Counter), Accident(Counter), 0, 1000)

PicDisplay.Print area(Counter); Tab(20); Accident(Counter); Tab(27); "accidents"

End Sub

Public Sub BiggestArea(ByRef area() As String, ByRef Accident() As Single, ByRef Biggest As Integer, ByVal numlist As Integer)

Call FindTheMaximum(Accident(), Biggest, numlist)

PicDisplay.Print
PicDisplay.Print "The Biggest number of accidents was " & Biggest
PicDisplay.Print

End Sub

Public Sub Search(ByRef Accident() As Single, ByVal Biggest As Integer, ByVal Counter As Integer, ByRef area() As String, ByVal numlist As Integer)

For Counter = 0 To numlist

If Accident(Counter) = Biggest Then
PicDisplay.Print area(Counter) & " had the worst accident rate"
End If
Next

End Sub

Private Sub Cmdquit_Click()

Call QuitProgram

End Sub

right the problem is when i am entering the number of accidents if i want to quit it dosen't it just says the messagebox even if i alt f4 it. so how can i quit at this stage as when executed it wont let you quit once you click the start
See less See more
1 - 1 of 1 Posts
1 - 1 of 1 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top