1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

text purification

Discussion in 'Software Development' started by prahsy, Feb 10, 2005.

Thread Status:
Not open for further replies.
  1. prahsy

    prahsy Thread Starter

    Feb 10, 2005
    Hello guys Im having problems while im trying to accept strings from two different textBoxes into a third one. The problem starts when im trying to eliminate characters and allow only numbers. I have tried event handlers like textChanged but did not work.
  2. rhMattL19


    Feb 7, 2005
    Dim bCount as Byte
    Dim sCharacter as String

    For bCount= 1 to Len(CharacterField.Text)
    sCharacter = Mid(CharacterField.Text,bCount,1)

    Select Case Val(sCharacter)
    Case 48 to 57
    ' Is a number from 0 to 9

    Case 65 to 90
    ' Is A to Z

    Case 97 to 122
    ' Is a to z
    End Select

    Next bCount

    This is all completely guessed. I've done all this before, but it was a while back.

    There are several approaches to checking the individual character. This is checking the ASCII code, which I can't remember if I ever tried. Anyway, you can probably figure out what's goin' on here and switch it up any which way you like.

    This code would be done on the click event. Checking the entire string at once.

    OnKeyPress you may want, in which case ...

    Dim bCode As Byte

    bCode = Val(KeyAscii) ' I think it was KeyAscii anyway

    Select Case ..... (change sCharacter from previous block to bCode here)

    I don't feel very good right now, I'm just assuming this will maybe work for you .... no promises.

    I don't have Visual Basic installed right now, cannot check this out.

    If this doesn't go as planned, sorry. Least I gave it a quick shot.

    Good luck!
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/328952

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice