1. Soal A
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call progdowhile()
Call progfor()
End Sub
Sub progfor()
Dim I As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 5 = 0 Then
ListBox1.Items.Add("&" & I)
End If
Next
End Sub
Sub progdowhile()
Dim I As Integer
ListBox2.Items.Clear()
I = Val(TextBox1.Text)
Do While I <= Val(TextBox2.Text)
If I Mod 5 > 0 Then
ListBox2.Items.Add(I & "%")
End If
I = I + 1
End Sub
End Class
2.Soal B
End Class
2.Soal B
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I As Integer
Dim a, b As Integer
ListBox1.Items.Clear()
For I = Val(TextBox1.Text) To Val(TextBox2.Text)
If I Mod 2 = 0 Then
ListBox1.Items.Add(I)
a = a + I
Else
ListBox2.Items.Add(I)
b = b + I
End If
Next
TextBox3.Text = a
TextBox4.Text = b
End Sub
Tidak ada komentar:
Posting Komentar