I have to create an application that will display all the odd and even numbers between the input values of number 1 and number 2. Display the output in a lstOdd and lstEven listbox. I have no clue I need help please?
Option Strict On
Option Explicit On
Public Class frmOddEven
Dim number1, number2 As Integer
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
If (Not (IsNumeric(txtFirst.Text))) Or (Not (IsNumeric(txtSecond.Text))) Or (txtFirst.Text = Nothing) Or (txtSecond.Text = Nothing) Then
MessageBox.Show("You must enter two numbers")
Else
number1 = CInt(txtFirst.Text)
number2 = CInt(txtSecond.Text)
End If
If number1 = number2 Then
MessageBox.Show("The numbers are equal")
txtFirst.Clear()
txtSecond.Clear()
End If
If number1 = 0 Or number2 = 0 Then
MessageBox.Show("One of the numbers is zero")
txtFirst.Clear()
txtSecond.Clear()
End If
If number1 > number2 Then
If number1 > 0 Then
For i = 0 To number1
If ((i Mod number2) = 0) Then
lstOdd.Items.Add(i)
End If
Next i
ElseIf number1 < 0 Then
For i = 0 To number1 Step -1
If ((i Mod number2) = 0) Then
lstOdd.Items.Add(i)
End If
Next i
End If
End If
If number2 > number1 Then
If number2 > 0 Then
For i = 0 To number2
If ((i Mod number1) = 0) Then
lstEven.Items.Add(i)
End If
Next i
End If
ElseIf number2 < 0 Then
For i = 0 To number2 Step -1
If ((i Mod number1) = 0) Then
lstEven.Items.Add(i)
End If
Next i
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class