怎么样在TEXT1.TEXT只能输入一次“.”
其他的“.”不要
比如5...3  5.35.35
只能是5.3  5.3535

解决方案 »

  1.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = Asc(".") Then
            If Len(Text1.Text) - Len(Replace(Text1.Text, ".", "")) > 0 Then KeyAscii = 0
        End If
    End Sub
      

  2.   

    If textbox1.Text.IndexOf(".") > 0 Then
                Exit Sub
            Else
                textbox1.Text = textbox1.text & "."
            End If
      

  3.   

    如果用keypress事件处理的话,你粘贴一下非法字符试一下看看。Dim s As StringPrivate Sub Text1_Change()
        Dim n As Long    If Not IsNumeric(Text1.Text) Then
            n = Text1.SelStart
            Text1.Text = s
            Text1.SelStart = n
        Else
            s = Text1.Text
        End If
    End Sub═══════════════════
    http://www.egooglet.com 资料、源码下载http://bbs.j2soft.cn 论坛交流
    ═══════════════════
      

  4.   

    if instr(text1,".")>1 then keyascii=0
      

  5.   

    2楼的是对的,但是又有一个新的问题
    我是text1(0).text
        text1(1).text
        text1(2).text
        text1(3).text
    把text1.text 控制了,其他的都不能输入“.”了
    有没有解决办法呀
      

  6.   

    Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
      '利用其中的Index來判斷是哪一個Text
    End Sub
      

  7.   

    jadeluo(秀峰) 的方法 +  DengXingJie(杰西) 的方法。
    :)
    晚了一步
      

  8.   

    Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
      '利用其中的Index來判斷是哪一個Text
    End Sub
    具体的语法是怎么样的呀
      

  9.   

    Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
        If KeyAscii = Asc(".")  And Index = 0 Then
            If Instr(Text1(0), ".") Then KeyAscii = 0
        End If
    End Sub
      

  10.   

    Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
    If KeyAscii = Asc(".") And Index = 0 Then
            If InStr(Text1(0), ".") Then KeyAscii = 0
        End If
    If KeyAscii = Asc(".") And Index = 0 Then
            If InStr(Text1(1), ".") Then KeyAscii = 0
        End If
    End Sub
    不可以呀
    text1(1).text 还是可以输入
      

  11.   

    要控制text1(0).text index=0 
    要控制text1(1).text index=1 
    要控制text1(2).text index=2
    要控制text1(3).text index=3
    ....
    在这里改:If KeyAscii = Asc(".") And Index = 0 Then