Answer:
See text attachment for complete source code (for the answer) where I used comments to explain each line of the program
Step-by-step explanation:
First, design the form using the following tools (and the accompanying properties) :
1 Label: Property: Text: Score
2 Buttons
Button1: Property: Name: btnAdd; Text: Add
Button2: Property: Name: btnDisplay; Text: Display
1 ListBox: Property: Visible: Hidden
1 TextBox: Property: Name: txtNum1
First, create the following function.
The function (named typecheck) validates input from the user (i.e. integer input only)
Function typecheck(ByVal input As String) As Boolean
Try
Convert.ToInt32(input)
End Try
End Function
It returns true if the input is integer and false, if otherwise.
Next, double-click on the "Add" button and write the following lines of code:
Dim num1 As String
num1 = txtNum1.Text
If num1 IsNot String.Empty Then
If typecheck(num1) Then
Else
Else
Next, double-click on the "Display" button and write the following lines of code:
If ListBox1.Items.Count > 0 Then
max1 = Convert.ToInt32(ListBox1.Items(0))
max2 = Convert.ToInt32(ListBox1.Items(0))
If Convert.ToInt32(ListBox1.Items(
)) >= max1 Then
max1 = Convert.ToInt32(ListBox1.Items(
))
Next
If Convert.ToInt32(ListBox1.Items(
)) >= max2 And Convert.ToInt32(ListBox1.Items(
)) < max1 Then
max2 = Convert.ToInt32(ListBox1.Items(
))
Next
MsgBox("Highest Scores: " + max1.ToString() + " " + max2.ToString())
MsgBox("
: " + ListBox1.Items.Count.ToString())
ListBox1.Items.Clear()