Friday, April 1, 2011

Digital Time

Private Sub Command1_Click()
End
End Sub

Private Sub Command3_Click()
If Command3.Caption = "&stop" Then
Command3.Caption = "&start"
Timer2.Enabled = False
Else
Command3.Caption = "&stop"
Timer2.Enabled = True
End If
End Sub


Private Sub Form_Load()
Label2.Caption = Format(Now, "DDDD, d mmmm yyyy hh:mm:ss")
End Sub

Private Sub Timer1_Timer()
Label2.Caption = Format(Now, "DDDD, d mmmm yyyy hh:mm:ss")
End Sub

Private Sub Timer2_Timer()
Dim s As String
s = Label1.Caption
s = Mid(s, 2, Len(s) - 1) & Left(s, 1)
Label1.Caption = s
End Sub

Select Case

Dim NilaiTm As Integer
Dim NilaiMid As Integer
Dim NilaiFinal As Integer
Dim NilaiAkhir As Integer
Dim Grade As String

Private Sub Command1_Click()
NilaiTm = Val(Text1.Text)
NilaiMid = Val(Text2.Text)
NilaiFinal = Val(Text3.Text)
NilaiAkhir = NilaiTm * 0.2 + NilaiMid * 0.3 + NilaiFinal * 0.5
Select Case NilaiAkhir

Case Is < 55
Grade = "E"
Case 55 To 64
Grade = "D"
Case 65 To 74
Grade = "C"
Case 75 To 84
Grade = "B"
Case Else
Grade = "A"
End Select
Text4.Text = NilaiAkhir
Text5.Text = Grade
End Sub

Private Sub Command2_Click()
Form3.Show
Hide
End Sub

Private Sub Command3_Click()
End
End Sub

Form Login VB to Access

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQL, Pesan As String

Private Sub Command2_Click(Index As Integer)
    If Text1.Text = "" Then
        MsgBox "Masukkan Username dengan benar", vbInformation
        Text1.SetFocus
        Exit Sub
    End If
    If Text2.Text = "" Then
        MsgBox "Masukkan Password dengan benar", vbInformation
        Text2.SetFocus
        Exit Sub

    End If
SQL = "select * from username where username='" & Text1 & "'and password='" & Text2 & "'"
Set rs = New ADODB.Recordset
rs.Open SQL, con, adOpenDynamic, adLockOptimistic, adCmdText
If Not rs.EOF Then
Text1.SetFocus
Text2.SetFocus
Else
    Pesan = MsgBox("Silahkan Anda isi dengan benar", vbInformation)
    Text1.SetFocus
    Text2.SetFocus
    Exit Sub
End If
sisgud.Show (modal)
Unload Me
End Sub


Private Sub Command1_Click(Index As Integer)
Pesan = MsgBox("Apakah Anda Ingin Keluar ?", vbYesNo + vbQuestion, "Konfirmasi Keluar")
If Pesan = vbYes Then
     End
  End If
End Sub

Private Sub Form_Load()
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\ahroihan\Documents\tes vb\db1.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
End Sub