怎么样才能使2进制转为10进制?
用如下代码能达到提问者目的。
Option Explicit
Private Sub Form_Load()
Text1 = "": Text2 = ""
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If Mid(Text1, Len(Text1), 1) = 0 Or Mid(Text1, Len(Text1), 1) = 1 Then 'Or KeyAscii = 49
Text1 = UCase$(Text1)
Text2 = "输入正确。 "
Text2。BackColor = vb...全部
用如下代码能达到提问者目的。
Option Explicit
Private Sub Form_Load()
Text1 = "": Text2 = ""
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If Mid(Text1, Len(Text1), 1) = 0 Or Mid(Text1, Len(Text1), 1) = 1 Then 'Or KeyAscii = 49
Text1 = UCase$(Text1)
Text2 = "输入正确。
"
Text2。BackColor = vbGreen
Else
Text1。SelStart = Len(Text1) - 1
Text1。
SelLength = 1
Text2 = "输入错误!"
Text2。BackColor = vbRed
End If
End Sub
也可用himlai和风舞冰尘的代码做改动,如下:
Option Explicit
Private Sub Form_Load()
Text1 = "": Text2 = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > 49 Or KeyAscii < 48 Then
Text2。
Text = "Wrong"
KeyAscii = 0
Else
Text2。Text = "Right"
End If
End Sub
。
收起