Minggu, 27 Juni 2010

Menghitung Persegi Panjang













Coding Program Menghitung Luas Persegi Panjang


Private Sub cmd_proses_Click()
If opt_luas.Value = True Then
txt_hasil.Text = Val(txt_1.Text) * Val(txt_2.Text)
ElseIf opt_panjang.Value = True Then
txt_hasil.Text = Val(txt_1.Text) / Val(txt_2.Text)
Else
txt_hasil.Text = Val(txt_1.Text) / Val(txt_2.Text)
End If
End Sub

Private Sub cmd_ulang_Click()
Label1.Caption = "PANJANG"
Label2.Caption = "LEBAR"
opt_luas.Value = True
txt_1.Text = ""
txt_2.Text = ""
txt_hasil.Text = ""
End Sub

Private Sub Command1_Click()
MsgBox "Yakin Anda mau keluar sekarang...?", vbInformation + vvokonly, "Keluar"
End
End Sub

Private Sub opt_lebar_Click()
If opt_lebar.Value = True Then
Label1.Caption = "LUAS"
Label2.Caption = "PANJANG"
End If
End Sub

Private Sub opt_luas_Click()
If opt_luas.Value = True Then
Label1.Caption = "PANJANG"
Label2.Caption = "LEBAR"
End If
cmd_proses.SetFocus
End Sub

Private Sub opt_panjang_Click()
If opt_panjang.Value = True Then
Label1.Caption = "LUAS"
Label2.Caption = "LEBAR"
End If
End Sub

Private Sub txt_1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 65 And KeyAscii <= 90 Or KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = 0
KeyAscii = 0
End If
If KeyAscii = 13 Then
txt_2.SetFocus
End If
End Sub

Private Sub txt_2_Change()
If KeyAscii >= 65 And KeyAscii <= 90 Or KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = 0
KeyAscii = 0
End If
End Sub

Private Sub txt_hasil_Change()
If KeyAscii >= 65 And KeyAscii <= 90 Or KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = 0
KeyAscii = 0
End If
txt_hasil.Enabled = False
End Sub

Tidak ada komentar:

Posting Komentar