Thứ Năm, 9 tháng 5, 2013

Code so sánh Max Min


Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long, LN As Long, NN As Long
a = Text1.Text
b = Text2.Text
c = Text3.Text
If a >= b Then
 LN = a
 NN = b
If c >= LN Then LN = c
If c <= NN Then NN = c
Text4.Text = LN
Text5.Text = NN
Else
 LN = b
 NN = a
If c >= LN Then LN = c
If c <= NN Then NN = c
Text4.Text = LN
Text5.Text = NN
End If
End Sub

Private Sub Command2_Click()
Text4.Text = " "
Text5.Text = " "
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
End Sub


Private Sub Text1_KeyPress(KeyAscii As Integer)
 ' ma Ascii cua 0 la 48, cua 9 la 57
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub



Private Sub Text2_KeyPress(KeyAscii As Integer)
 ' ma Ascii cua 0 la 48, cua 9 la 57
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub



Private Sub Text3_KeyPress(KeyAscii As Integer)
 ' ma Ascii cua 0 la 48, cua 9 la 57
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub




Không có nhận xét nào:

Đăng nhận xét