Hello everyone its me again try to learn VB. I need help to make sure if my code needs to be modify. Here is the instruction:
1- The list box that contains the city names is not visible when the program runs.
lstCity.Visible = Not lstCity.Visible (still showing at run time)?
2- Determine and Display the Price:
(Your ticket from Boston to Los Angeles costs $) output
3- The base price for a ticket on a flight that does not leave the zone is $250, and the base price for any flight that travels from one zone to another is $400.
4- Additional Fees
Regardless of the base price, add 30% for a business class ticket, and add 60% for a first class ticket.
5- Zone Airports
Zone 1 (West Coast) LAX & SFO
Zone 2 (East Coast) BOS, BWI, JFK, MIA
Zone 3 (Midwest) AUS, DFW, ORD
Public Class frmTicket
Private Sub btnDetermineRoute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDetermineRoute.Click
' Declare variables
Dim fromCity, toCity, fromName, toName As String
Dim fromZone, toZone, ticketPrice As Double
'Dim businessClass, firstClass As Double
' input from the list box
fromCity = lstFrom.Text
fromName = lstFrom.Text
toCity = lstTo.Text
toName = lstTo.Text
' Select From City
If (fromCity = "LAX" Or fromCity = "SFO") Then
fromZone = 1
ElseIf (fromCity = "BOS" Or fromCity = "BWI" Or fromCity = "JFK" Or fromCity = "MIA") Then
fromZone = 2
Else
fromZone = 3
End If
' Select to City
If (toCity = "LAX" Or toCity = "SFO") Then
fromZone = 1
ElseIf (toCity = "BOS" Or toCity = "BWI" Or toCity = "JFK" Or toCity = "MIA") Then
fromZone = 2
Else
fromZone = 3
End If
' Select From City
If (fromCity = "AUS") Then
fromName = "Austin"
ElseIf (fromCity = "BOS") Then
fromName = "Boston"
ElseIf (fromCity = "BWI") Then
fromName = "Baltimore"
ElseIf (fromCity = "DFW") Then
fromName = "Dallas"
ElseIf (fromCity = "JFK") Then
fromName = "New York"
ElseIf (fromCity = "LAX") Then
fromName = "Los Angeles"
ElseIf (fromCity = "MIA") Then
fromName = "Miami"
ElseIf (fromCity = "ORD") Then
fromName = "Chicago"
ElseIf (fromCity = "SFO") Then
fromName = "San Francisco"
End If
' Select To City
If (toCity = "AUS") Then
toName = "Austin"
ElseIf (toCity = "BOS") Then
toName = "Boston"
ElseIf (toCity = "BWI") Then
toName = "Baltimore"
ElseIf (toCity = "DFW") Then
toName = "Dallas"
ElseIf (toCity = "JFK") Then
toName = "New York"
ElseIf (toCity = "LAX") Then
toName = "Los Angeles"
ElseIf (toCity = "MIA") Then
toName = "Miami"
ElseIf (toCity = "ORD") Then
toName = "Chicago"
ElseIf (toCity = "SFO") Then
toName = "San Francisco"
End If
' Id the user has not chosen both a From city and a
' To City - provide a warning to selected BOTH a
' from and ti city
If (fromCity = "" Or toCity = "") Then
lblWarning.Text = "You must selected both a from to city"
lblWarning.Visible = True
End If
' Function
If (fromCity = toCity) Then
lblWarning.Text = "You must selected different cities!"
lblWarning.Visible = True
txtMessage.Text = ""
Else
' Calculate the Ticket Price
If (fromZone = toZone) Then
ticketPrice = 250
Else
ticketPrice = 400
End If
' Seat class to modify ticket price
If radBusinessClass.Checked Then
ticketPrice = ticketPrice * 1.3
ElseIf radFirstClass.Checked Then
ticketPrice = ticketPrice * 1.6
End If
' Display the route in the text box
txtMessage.Text = "Your ticket from " + fromName + " to " + toName + " costs " + CStr(FormatCurrency(ticketPrice))
lblWarning.Visible = False
' Not visibke at run time
lstCity.Visible = Not lstCity.Visible
End If
End Sub
End Class