Results 1 to 5 of 5

Thread: all characters except '\' appear in textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Ruinen, Drente, Netherlands
    Posts
    192
    How to put any character in a textbox EXCEPT the backslash ?

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Do you need to remove all the "\" or do you want these to be left in a variable?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    Try this to disallow a "\" from being entered into the TextBox:
    Code:
    Private Sub Text1_Change()
       Dim lPrevPos As Long
       
       If InStr(1, Text1.Text, "\") Then
          lPrevPos = Text1.SelStart - 1
          Text1.Text = Replace(Text1.Text, "\", vbNullString)
          
          If lPrevPos > Len(Text1.Text) Then
             Text1.SelStart = Len(Text1.Text)
          Else
             Text1.SelStart = lPrevPos
          End If
          
       End If
    End Sub
    [Edited by SonGouki on 04-29-2000 at 05:16 PM]
    Dan PM
    Analyst Programmer

    VB6 SP3 (also VB4 16-bit sometimes )

  4. #4
    Member
    Join Date
    Jan 1999
    Posts
    41
    Or can do something like this

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 92 Then
    KeyAscii = 0
    End If
    End Sub

  5. #5
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217

    Thumbs down

    mlana,
    That will work fine for regular typing into the TextBox, but is useless when the user pastes. My code disallows the undesired string completely, try it out
    Dan PM
    Analyst Programmer

    VB6 SP3 (also VB4 16-bit sometimes )

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