if Listbox1.SelectedItem.Text="For..next" then
เรียกโค้ดคำนวน
else if Listbox1.SelectedItem.Text="Do wheile loop" then
เรียกโค้ดคำนวน
else if Listbox1.SelectedItem.Text="Do Loop until" then
เรียกโค้ดคำนวน
else if Listbox1.SelectedItem.Text="Do Loop while" then
เรียกโค้ดคำนวน
End if
Function fac(ByVal n As Integer)
If n < 3 Then
Return n
Else
Return n * fac(n - 1)
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.SelectedItem.Text = "For next" Then
Dim count As Integer
Dim n As Integer
n = Val(TextBox1.Text)
For count = 1 To n
Label5.Text = fac(count)
Next
ElseIf ListBox1.SelectedItem.Text = "Do wheile loop" Then
Dim count As Integer = 1
Dim a As Integer
Dim total As Integer
a = Val(TextBox1.Text)
Do While a >= count
total = a * count
count = count + 1
Label5.Text = total
Loop
End If
End Sub
End Class