Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim datauser As ADODB.Recordset
- Dim kodeid As ADODB.Recordset
- Private Sub AutoNomor()
- Set kodeid = conn.Execute("select * from mahasiswa order by idmahasiswa desc")
- With kodeid
- If .EOF Then
- txtnim.Text = "MHS" & "001"
- Else
- txtnim.Text = "MHS" & Right(Str(Val(Right(.Fields(0), 3)) + 1001), 3)
- End If
- End With
- End Sub
- Sub aktif()
- txtnama.Enabled = True
- txtjurusan.Enabled = True
- txtnohp.Enabled = True
- End Sub
- Sub nonaktif()
- txtnim.Enabled = False
- txtnama.Enabled = False
- txtjurusan.Enabled = False
- txtnohp.Enabled = False
- End Sub
- Sub bersih()
- txtnim.Text = ""
- txtnama.Text = ""
- txtjurusan.Text = ""
- txtnohp.Text = ""
- End Sub
- Private Sub cmdinput_Click()
- If cmdinput.Caption = "INPUT" Then
- aktif
- cmdinput.Caption = "SIMPAN"
- txtnama.SetFocus
- AutoNomor
- ElseIf cmdinput.Caption = "SIMPAN" Then
- Set datauser = New ADODB.Recordset
- query = "insert into mahasiswa values ('" & txtnim.Text & "', '" & txtnama.Text & "','" & txtjurusan.Text & "','" & txtnohp.Text & "')"
- conn.Execute query
- Set datauser = New ADODB.Recordset
- datauser.Open "select * from mahasiswa", conn
- Set DataGrid1.DataSource = datauser
- MsgBox "Data Berhasil Disimpan"
- End If
- End Sub
- Private Sub Form_Load()
- bersih
- nonaktif
- Set datauser = New ADODB.Recordset
- datauser.Open "select * from mahasiswa", conn
- Set DataGrid1.DataSource = datauser
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement