Results 1 to 4 of 4

Thread: Now that's a question

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Vilnius, Lithuania
    Posts
    50

    Post

    HI.

    Ok let's say i have the textbox and my code is:

    Code:
    Private Sub txt1_KeyPress(KeyAscii As Integer)
    
    If KeyAscii > 57 Or KeyAscii = 32 Or KeyAscii = 33 Or KeyAscii = 35 Or KeyAscii = 36 Or KeyAscii = 37 Or KeyAscii = 38 Or KeyAscii = 40 Or KeyAscii = 41 Or KeyAscii = 42 Or KeyAscii = 43 Or KeyAscii = 44 Or KeyAscii = 45 Or KeyAscii = 47 Then
      KeyAscii = 0
    
    End If
    
    End Sub
    This code prevents text writing in the textbox.

    And the question Is: How can i prevent
    writing of second dot?

    for egzample 2.1133...
    or 654.15.

  2. #2
    Guest

    Post

    Use the InStrRev function and search for
    a "." in the text.

  3. #3
    Member
    Join Date
    Jan 1999
    Location
    Garden Grove, CA, Orange
    Posts
    55

    Post


    Private Sub txt1_KeyPress(KeyAscii As Integer)
    ' Allow only "(34), '(39), .(46), 0~9(48~57)
    ' I also allow "Backspace"(8)

    If KeyAscii <> 34 And KeyAscii <> 39 And KeyAscii <> 46 _
    And KeyAscii <> 8 And Not (KeyAscii > 47 And KeyAscii < 58) Then
    KeyAscii = 0
    ElseIf KeyAscii = 46 Then
    If InStr(1, txt1, ".") > 0 Then KeyAscii = 0
    End If

    End Sub


    HTH
    Joon

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 1999
    Location
    Vilnius, Lithuania
    Posts
    50

    Post

    That's a bit complicated but i'll try to understand

    thanx

    -casparas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width