vb中TEXT问题

来源:百度知道 编辑:UC知道 时间:2024/07/03 04:24:52
请问一个VB问题 是TEXT的 我在TEXT的KEYPRESS()事件中写入了:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Text1.Text = 0 And KeyAscii = 46 Then
Text1.Text = Text1.Text + "."
End If
End Sub
我想要输入.时 是"0"+"." ="0." 可怎么输入. 就变成了".0."呢 真的想不通哦 有什么办法可以实现吗??在线等了

If Val(Text1.Text) = 0 And KeyAscii = 46 Then
Text1.Text = Text1.Text + "."
End If
KeyAscii = 0 '添加这句 要把多余的输入去掉!

不懂

Private Sub Text1_KeyPress(KeyAscii As Integer)
If Val(Text1.Text) = 0 And KeyAscii = 46 Then
Text1.Text = "0"
Text1.SelStart = 1
End If
End Sub

If Text1.Text = 0 And KeyAscii = 46 Then 改为
If Text1.Text = "0" And KeyAscii = 46 Then 就行了

Private Sub Text1_KeyPress(KeyAscii As Integer)
If Text1.Text = 0 And KeyAscii = 46 Then
Text1.Text = Text1.Text + "."
KeyAscii = 0
End If
End Sub