• Membuat login pada VB.net
• Klik kanan pada project yang dibuat
• Add -> New item-> login form
• Klik 2x pada tombol ok
• Masukan sintax
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
If UsernameTextBox.Text = "robby" And PasswordTextBox.Text = "ganteng" Then
MDIParent1.Show()
Me.Visible = False
Else
MsgBox("login gagal,coba ulangi lagi")
End If
End Sub
* Lalu jalankan / running program tersebut
* Masukan username “robby” dan password “ganteng”
• Jika sudah bisa login dan muncul MDI Parent Form maka Login telah selesai.
ATMANTO KUNCORO
Kamis, 09 Juni 2011
vb3
Public Class Form2
Sub kosong()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End Sub
Sub netral()
Button1.Text = "Tambah"
Button2.Text = "Ubah"
Button3.Text = "Hapus"
Button4.Text = "Keluar"
Button1.Enabled = True 'enable=funsi aktif/tdaknya sebuah objek
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
End Sub
Sub celrecord()
Call bukakoneksi()
tampil2.Connection = database
tampil2.CommandType = CommandType.Text
tampil2.CommandText = "select * from jurusan where kdjur='" & Trim(TextBox1.Text) & "'"
tampilkan = tampil2.ExecuteReader
If tampilkan.HasRows = True Then ''ada atau tidak recod yg dimaksukkan
hasilcek = True
Else
hasilcek = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call simpankelompok()
End Sub
Sub simpankelompok()
If Button1.Text = "Tambah" Then
TextBox1.Text = ""
Button1.Text = "Simpan"
Button2.Enabled = False
Button3.Enabled = False
Button4.Text = "Batal"
TextBox1.Focus()
Else
If TextBox1.Text = "" Then Exit Sub ''then exit sub = keluar dari sub class dgan syarat textbox harus diisi/pengecekan validasi
If TextBox2.Text = "" Then Exit Sub
Call celrecord()
Try
If hasilcek = "False" Then
Call bukakoneksi()
tampil2.Connection = database
tampil2.CommandType = CommandType.Text
tampil2.CommandText = " Insert into Jurusan (kdjur,nmjur)values ('" & TextBox1.Text & "','" & TextBox2.Text & "')"
tampil2.ExecuteNonQuery()
Call kosong()
Else
MsgBox("Data sudah ada , silahkan cek data yang akan diinput ", MsgBoxStyle.Critical, "Input data") ''critical = ! dalam msgbox
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End If
vb2
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call bukakoneksi()
End Sub
Sub Jurusan()
Call bukakoneksi()
Tampil2.Connection = database
Tampil2.CommandType = CommandType.Text
tampil2.CommandText = "select * from jurusan where kdjur='" & Trim(TextBox1.Text) & "'"
Tampilkan = Tampil2.ExecuteReader
If Tampilkan.HasRows = True Then
While Tampilkan.Read()
If IsDBNull(tampilkan("kdjur")) Then
Else
TextBox2.Text = tampilkan("nmjur")
End If
End While
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call Jurusan()
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call bukakoneksi()
End Sub
Sub Jurusan()
Call bukakoneksi()
Tampil2.Connection = database
Tampil2.CommandType = CommandType.Text
tampil2.CommandText = "select * from jurusan where kdjur='" & Trim(TextBox1.Text) & "'"
Tampilkan = Tampil2.ExecuteReader
If Tampilkan.HasRows = True Then
While Tampilkan.Read()
If IsDBNull(tampilkan("kdjur")) Then
Else
TextBox2.Text = tampilkan("nmjur")
End If
End While
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call Jurusan()
End Sub
End Class
vbkoneksi
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call bukakoneksi()
End Sub
Sub Jurusan()
Call bukakoneksi()
Tampil2.Connection = database
Tampil2.CommandType = CommandType.Text
tampil2.CommandText = "select * from jurusan where kdjur='" & Trim(TextBox1.Text) & "'"
Tampilkan = Tampil2.ExecuteReader
If Tampilkan.HasRows = True Then
While Tampilkan.Read()
If IsDBNull(tampilkan("kdjur")) Then
Else
TextBox2.Text = tampilkan("nmjur")
End If
End While
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call Jurusan()
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call bukakoneksi()
End Sub
Sub Jurusan()
Call bukakoneksi()
Tampil2.Connection = database
Tampil2.CommandType = CommandType.Text
tampil2.CommandText = "select * from jurusan where kdjur='" & Trim(TextBox1.Text) & "'"
Tampilkan = Tampil2.ExecuteReader
If Tampilkan.HasRows = True Then
While Tampilkan.Read()
If IsDBNull(tampilkan("kdjur")) Then
Else
TextBox2.Text = tampilkan("nmjur")
End If
End While
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call Jurusan()
End Sub
End Class
Kamis, 14 April 2011
uts
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
For a = Val(TextBox1.Text) To Val(TextBox2.Text)
If a Mod 3 = 0 Or a Mod 4 = 0 Or a Mod 7 = 0 Then
ListBox1.Items.Add(a)
Else
ListBox2.Items.Add(a)
End If
Next
For a = Val(TextBox1.Text) To Val(TextBox2.Text)
If a Mod 7 = 0 Then
ListBox3.Items.Add(a)
Else
If a Mod 8 = 0 Then
ListBox3.Items.Add(a)
End If
End If
Next
If Button1.Text = "Proses" Then
Button1.Text = "Sudah Di Proses"
End If
Button2.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Call bersih()
If Button1.Text = "Sudah Di Proses" Then
Button1.Text = "Proses"
End If
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
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
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
End Class
Dim a As Integer
For a = Val(TextBox1.Text) To Val(TextBox2.Text)
If a Mod 3 = 0 Or a Mod 4 = 0 Or a Mod 7 = 0 Then
ListBox1.Items.Add(a)
Else
ListBox2.Items.Add(a)
End If
Next
For a = Val(TextBox1.Text) To Val(TextBox2.Text)
If a Mod 7 = 0 Then
ListBox3.Items.Add(a)
Else
If a Mod 8 = 0 Then
ListBox3.Items.Add(a)
End If
End If
Next
If Button1.Text = "Proses" Then
Button1.Text = "Sudah Di Proses"
End If
Button2.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Call bersih()
If Button1.Text = "Sudah Di Proses" Then
Button1.Text = "Proses"
End If
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
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
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
End Class
Kamis, 31 Maret 2011
latihan soal uts
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b, c, d, f, g, j As Integer
a = 7
b = 8
For f = Val(TextBox1.Text) To Val(TextBox2.Text)
If f Mod 3 = 0 Or f Mod 4 = 0 Or f Mod 7 = 0 Then
ListBox1.Items.Add(f)
Else
j = f
ListBox2.Items.Add(j)
End If
Next
For g = Val(TextBox1.Text) To Val(TextBox2.Text)
Next
For c = Val(TextBox1.Text) To Val(TextBox2.Text)
If c Mod a = 0 Then
d = c
ListBox3.Items.Add(d)
Else
If c Mod b = 0 Then
d = c
ListBox3.Items.Add(d)
End If
End If
Next
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Call bersih()
End Sub
End Class
materi2 tambahan 2
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "TI" Then
TextBox2.Text = "teknik informatika"
Else
If TextBox1.Text = "SI" Then
TextBox2.Text = "sistem informasi"
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Add(TextBox3.Text + " " + TextBox4.Text + " " + TextBox5.Text + " " + TextBox6.Text + " " + TextBox7.Text)
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
TextBox4.Focus()
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
If e.KeyChar = Chr(13) Then
TextBox5.Focus()
End If
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
If e.KeyChar = Chr(13) Then
TextBox6.Focus()
End If
End Sub
Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
If e.KeyChar = Chr(13) Then
TextBox7.Focus()
End If
End Sub
Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
If e.KeyChar = Chr(13) Then
ListBox1.Items.Add(TextBox3.Text + " " + TextBox4.Text + " " + TextBox5.Text + " " + TextBox6.Text + " " + TextBox7.Text)
Call bersih()
End If
End Sub
Sub bersih()
TextBox3.text = ""
TextBox4.text = ""
TextBox5.text = ""
TextBox6.text = ""
TextBox7.text = ""
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
Button1.Focus()
End If
End Sub
End Class
Langganan:
Postingan (Atom)