VB中怎么表示正数

2025-04-13 17:10:13
推荐回答(1个)
回答(1):

Dim a As Integer

Dim b As Integer

Dim c As Integer

Private Sub Text1_KeyPress(KeyAscii As Integer)

If InStr("0123456789" & Chr(8) & Chr(9), Chr(KeyAscii)) = 0 Then KeyAscii = 0

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

If InStr("0123456789" & Chr(8) & Chr(9), Chr(KeyAscii)) = 0 Then KeyAscii = 0

End Sub

Private Sub Command1_Click()

a = Val(Text1.Text)

b = Val(Text2.Text)

c = a * 0.4 + b * 0.6

If c >= 60 Then

Text3.Text = "合格"

Else

Text3.Text = "不合格"

End If

End Sub

望采纳。。。。