Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("For Next")
ListBox1.Items.Add("Do While Loob")
ListBox1.Items.Add("Do Loob Until")
ListBox1.Items.Add("Do Loob While")
End Sub
Sub Result()
Dim a As Int32
Dim fac As Int32 = 1
Dim i As Int32
a = Val(TextBox1.Text)
For i = a To 1 Step -1
fac = fac * i
Next
Label5.Text = fac
End Sub
Sub Resule1()
Dim a1 As Int32
Dim fac1 As Int32 = 1
Dim i1 As Int32 = 1
a1 = Val(TextBox1.Text)
Do While a1 >= i1
fac1 = fac1 * i1
i1 = i1 + 1
Loop
Label5.Text = fac1
End Sub
Sub Resule2()
Dim a2 As Int32
Dim fac2 As Int32 = 1
Dim i2 As Int32 = 1
a2 = Val(TextBox1.Text)
Do
fac2 = a2 * i2
i2 = i2 + 1
Loop Until a2 >= i2
Label5.Text = fac2
End Sub
Sub Resule3()
Dim i3 As Integer = 1
Dim a3 As Integer
Dim fac3 As Integer = 1
a3 = Val(TextBox1.Text)
Do
fac3 = fac3 * i3
i3 = i3 + 1
Loop While a3 >= i3
Label5.Text = fac3
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.Text = "For Next" Then
Call Result()
ElseIf ListBox1.Text = "Do While Loob" Then
Call Resule1()
ElseIf ListBox1.Text = "Do Loob Until" Then
Call Resule2()
ElseIf ListBox1.Text = "Do Loob While" Then
Call Resule3()
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
End Class