Sei sulla pagina 1di 2

Example program 1 -

Capital City
The code for the program below ask the user the capital city
of England and display a suitable message depending on
whether they enter London.
Interface

Code when btnCheck is clicked

'stores the user selection from the combo box in the variable city

Dim city As String = cmbCity.Text

'checks if the city variable has London stored in it

If city = "London" Then

'displays correct if the condition is true

MessageBox.Show("Correct, the capital city of England is: " & city)

Else

'displays wrong if they have entered something else

MessageBox.Show("Wrong, try again!")


End If

This is what happens when the button is clicked:

Potrebbero piacerti anche