Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to strip a $ sign out of a variable 2

Status
Not open for further replies.

Grizz2

Programmer
Dec 4, 2001
52
US
Hi All,
I was trying to find the easiest way to either not allow a $ sign to be entered in an input box, or to check for and strip this character out of the resulting variable.
Thanks
Grizz2
 
Split - Join - Seperator = "$" -
Boom - Done.

(Split and Join are vb functions - introduced in VB6)

Probably used in a lost focus function.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Can't get much simpler than that eh.
Thanks
 
Hi,

If you wanted them to stop entering the $ into the input box then use

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = Asc("$") Then KeyAscii = 0

End Sub

This is in the Keypress event of your text box. when they press the $ nothing appears in the textbox. You might also want to put a Beep or a message to tell them it is an illegal key press.
Any Help, Yes/No let me know

Regards

________________________________________
Is not a fool a wise man in his own eyes - Proverbs
 
Laffalot's solution applies to a TextBox, not to an InputBox

If you want to use the latter (your choice) then the following statement strips it of any $ sign.

strInput = Replace(InputBox("Enter a New Text"), "$", "")

Be aware that in this case the user has no visible clue that you stripped the $ signs ....
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Thanks for all the help.
The keypress code was my first thought but couldn't figure how to associate it with the input box.
The split() from above worked fine but I ended up using the Replace() from rvBasics post since this used the least amount of code.
Thanks Again
Grizz2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top