PROGRAM VB
Berikut adalah program VB yang menggunakan listbox dan combobox..dengan tampilan form sebagai berikut ;
kemudian menuliskan programnya sebagai berikut ;
Public Class Form2
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
Button1.Focus()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
For i = 5 To Val(TextBox2.Text)
If (i Mod 2 = 0) Then
ListBox1.Items.Add(i * -1)
Else
ListBox1.Items.Add(i)
End If
Next
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
ComboBox1.Items.Add(TextBox1.Text)
End If
End Sub
End Class
dirunning maka akan tampil seperti ini :Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
Button1.Focus()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
For i = 5 To Val(TextBox2.Text)
If (i Mod 2 = 0) Then
ListBox1.Items.Add(i * -1)
Else
ListBox1.Items.Add(i)
End If
Next
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
ComboBox1.Items.Add(TextBox1.Text)
End If
End Sub
End Class
demikian program yang saya buat, siap dipakai dan siap dijalankan,,,, thanks
Tidak ada komentar:
Posting Komentar