Rabu, 26 Februari 2014

Pangkat Kuadrat


Private Sub CmdKeluar_Click()
    DoCmd.Close
End Sub

Private Sub CmdPassword_Click()
Dim Password As String
Password = "user" ' isi variable password

If CmdPassword.Caption = "Hasil" Then 'Menguji Caption Tombol
    Me.AllowEdits = False
    CmdPassword.Caption = "Edit Data" 'Mengembalikan Caption Semula
    TxtHasilKuadrat = Val(TxtKuadrat ^ 2)
Else
    If InputBox("Masukkan Password Anda : ", "Password") = "user" Then
        Me.AllowEdits = True 'Form dapat di edit
        TxtKuadrat = ""
        TxtHasilKuadrat = ""
        TxtKuadrat.SetFocus
        CmdPassword.Caption = "Hasil" 'Mengubah Caption Tombol Menjadi Tombol Hasil
    Else
        MsgBox ("Password Anda Salah") 'Menampilkan Message Box
    End If
End If
End Sub

Private Sub Form_Load()
    CmdPassword.Caption = "Edit Data" 'Posisi caption tombol pertama kali
    TxtKuadrat.SetFocus
    Me.AllowEdits = False 'Form tidak dapat di edit
End Sub

Rabu, 12 Februari 2014

Kalkulator Kiwiiwew

Private Sub CmdHapus_Click()
 TxtBil1 = ""
 TxtBil2 = ""
 TxtHasil = ""
 TxtBil1.SetFocus
End Sub
Private Sub CmdKali_Click()
  Bil1 = Val(TxtBil1)
  Bil2 = Val(TxtBil2)
   Hasil = Bil1 * Bil2
   TxtHasil = Hasil
End Sub
Private Sub CmdKeluar_Click()
 DoCmd.Save
  DoCmd.Close
End Sub
Private Sub CmdKurang_Click()
 Bil1 = Val(TxtBil1)
 Bil2 = Val(TxtBil2)
  Hasil = Bil1 - Bil2
  TxtHasil = Hasil
End Sub

Private Sub CmdTambah_Click()
 Bil1 = Val(TxtBil1)
 Bil2 = Val(TxtBil2)
  Hasil = Val(TxtBil1)
  TxtHasil = Hasil
 End Sub