0

Hey, am having textbox, when ever any of these destinations is entered, then the price will be display on a label, i used these codes, but still not giving me the correct thing.

Dim Destinations() As String = {"Africa", "Americas", "Asia", "Europe", "Middle East", "Pacific Isles", "South East Asia"}
Dim Airfares() As Integer = {800, 1500, 1000, 2000, 1000, 400, 300}
Dim EnterDestination As String = DestinationTextBox.Text
Dim index As Integer
For index = 0 To Destinations.Length - 1
    If EnterDestination.ToUpper = Destinations(index) Then
        AnsLabel.text = (Airfares(index))
    End If
Next

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by nexocentric
0

From what I'm seeing here your problem maybe with this.

If EnterDestination.ToUpper = Destinations(index) Then

Using the ToUpper method makes the whole string uppercase. So if the user entered "hello" the string would become "HELLO" after calling ToUpper.

Take a look at the MSDN explaination of ToUpper function
http://msdn.microsoft.com/en-us/library/system.string.toupper(VS.71).aspx

One way to fix this would be to do the following:

If EnterDestination.ToUpper = Destinations(index).ToUpper Then
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.