Selasa, 14 November 2017

Tugas 6 Kalkulator menggunakan keypress


Private Sub Command1_Click()
If Val(Text1.Text) & Val(Text5.Text) Then
Text17.Text = Val(Text1.Text) + Val(Text5.Text)
End If

If Val(Text2.Text) & Val(Text6.Text) Then
Text18.Text = Val(Text2.Text) / Val(Text6.Text)
End If

If Val(Text3.Text) & Val(Text7.Text) Then
Text19.Text = Val(Text3.Text) - Val(Text7.Text)
End If

If Val(Text4.Text) & Val(Text8.Text) Then
Text20.Text = Val(Text4.Text) * Val(Text8.Text)
End If




End Sub

Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text17.Text = ""
Text18.Text = ""
Text19.Text = ""
Text20.Text = ""

End Sub

Private Sub Command4_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text17.Text = ""
Text18.Text = ""
Text19.Text = ""
Text20.Text = ""

End Sub

Private Sub Command5_Click()
End
End Sub

Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text17.Text = ""
Text18.Text = ""
Text19.Text = ""
Text20.Text = ""
End Sub


Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text5.SetFocus
End If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text6.SetFocus
End If

End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text7.SetFocus
End If

End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text8.SetFocus
End If

End Sub

0 komentar:

Posting Komentar