Larger and Smaller Code

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Public Class Form1

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


'Instructions for Exit button to closes application
Me.Close()
End Sub
Private Sub btnCompare_Click(sender As Object, e As EventArgs) Handles
btnCompare.Click
'Declare Local Variables
Dim intValueA As Integer
Dim intValueB As Integer
With Me
'Determine if value A is an integer
If Not Integer.TryParse(txtValueA.Text, intValueA) Then
.lblResults.Text = "Value A is not a valid number, try again."
With .txtValueA
.Focus()
.SelectAll()
End With
'Determine if value B is an integer
ElseIf Not Integer.TryParse(txtValueB.Text, intValueB) Then
.lblResults.Text = "Value B is not a valid number, try again."
With .txtValueB
.Focus()
.SelectAll()
End With
Else
'Determine which value is greater
Select Case True
Case intValueA = intValueB
.lblResults.Text = "The values are equal."
Case intValueA > intValueB
.lblResults.Text = "Value A is greater than value B"
Case intValueA < intValueB
.lblResults.Text = "Value B is greater than value A"
End Select
End If
End With
End Sub
End Class

You might also like