Hello there!
i am quite new to VB6 (Been learning it for 3 months at college) and im finding it very interesting and simple to program things with it, but i am however struggling with this perticular piece of work.
What i have created for a college assignment is a Hurricane category program. It works by asking the user to input the location(s) and windspeed(s) of various hurricanes.
Once the user has done this, the program tests the criteria to see what category each storm is, and what effect each category will have.
to get input from the user i first ask them how many storms they are watching, i then ask them to input the windspeed and locations. The information is stored in an array module so it can be used in other forms.
I also have a Previous / Next form with buttons that allow the user to see all of the storms they have entered with labels describing what course of action
depending on the category.
The Problem:
Here is the code to get input from the user.
VB Code:
amount(x) = InputBox("Please enter the amount of storms you are watching") If amount(x) < 1 Then MsgBox ("please enter a value") End If For x = 0 To amount(x) - 1 location(x) = InputBox("Please enter the location") speed(x) = InputBox("Please enter the speed in MPH") If speed(x) >= 74 And speed(x) <= 96 Then Category(x) = ("1") ElseIf speed(x) >= 97 And speed(x) <= 110 Then Category(x) = ("2") ElseIf speed(x) >= 111 And speed(x) <= 130 Then Category(x) = ("3") ElseIf speed(x) >= 131 And speed(x) <= 155 Then Category(x) = ("4") ElseIf speed(x) > 155 Then Category(x) = ("5") End If Next End Sub
This part works brilliantly, the data the user inputs is displayed in listboxes in the next form.
My problem lies here with my Previous / Next form
VB Code:
Private Sub CmdNext_Click() lbl5.Visible = False 'Counter control variable to display the next set of information 'entered by the user. A label is displayed if the category is 5, it 'tells the user to "EVACUATE" If x < amount(x) Then amount(x) = amount(x) + 1 Else amount(x) = 0 End If txtCategory.Text = Category(x) TxtLocation.Text = location(x) If txtCategory = "5" Then lbl5.Visible = True End If End Sub
VB Code:
Private Sub CmdPrev_Click() lbl5.Visible = False 'Counter control variable to display the previous set of information 'entered by the user. A label is displayed if the category is 5, it 'tells the user to "EVACUATE" If x > amount(x) Then x = amount(x) - 1 Else x = 0 End If txtCategory.Text = Category(x) TxtLocation.Text = location(x) If txtCategory = "5" Then lbl5.Visible = True End If End Sub
It will not loop round the data, ive tried all different combinations but i just cannot do it =\




Reply With Quote