text purification

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

prahsy

Thread Starter
Joined
Feb 10, 2005
Messages
1
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.
 
Joined
Feb 7, 2005
Messages
21
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!
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top