Cari

Senin, 07 Maret 2011

Contoh program sederhana Visual Basic



Dan ini scriptnya :



Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim j As Integer
ListBox1.Items.Clear()
For j = Val(TextBox1.Text) To Val(TextBox2.Text)
If j Mod 9 = 0 And j Mod 27 = 0 Then
ListBox1.Items.Add(j)
End If
Next
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim j As Integer
ListBox1.Items.Clear()
For j = Val(TextBox1.Text) To Val(TextBox2.Text)
If j Mod 2 = 3 Then
ListBox1.Items.Add(j)
End If
Next
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
ListBox1.Items.Clear()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
TextBox2.Focus()
End If
End Sub
End Class

1 komentar: