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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with textboxes !!! 1

Status
Not open for further replies.

ken35

Technical User
Feb 24, 2002
2
GB
hi please can someone help im new to vb6 so please be understanding if its been asked before but im trying to write my first project and have a few textboxes where the user enters a value which eventually through a series of boxes will give a grand total but there are 2 things i need help with one ...i would like the boxes to look like 00.00 and the values(nums) to alter as the user enters the data
the second is i dont want the user to make a mistake and enter any other characters only num and the decimal point
if there is a way to make the point be there fixed it would be great many thanks for your help and i hope i make sense
bye
 
Do you have the basic program, sans these dynamic formatting and entry vetting features?

The pretty feastures you want actually slow down the entry of information. They were necessary features way back in the dark ages of block mode terminals that would not interact with any intelligence until the whole screen was sent.

Today..most people are very comfortable typing their own decimal point and waiting until they navigate to the next field for an error check.

However, if this is a project for you to learn, then my suggestion would be to get the program working without these features and then continually refine your textbox into a smart-textbox; all the time keeping it working.
Look over the textbox events (change, keypress, etc that react to a keystroke and figure out use these to create the effect that you want.

dsb
 
hi thanks for replying but lost me now i have seen a few programs with this maybe i should explain the idea behind this its a couple of forms with a series of text boxes which the cashiers are entering the amount of money in to starting with change and then notes the program works but if i put in a alphabet say ( a )or some other wrong entry it takes it and just for the user i would like the boxes to have the 00.00 look and fixed decimal point i have read quuiet alot and can not find anything if anyone else has any other ideas it would be great
bye
thanks for your support
 
You might want to go to MSDN and enter a search for "MaskedEdit Control". This feature, I believe, allows you to set up a formatted input field. An example would be entering a phone number a user would see

(___) ___ -____

This can also be set up to display decimal points, etc.

Hope this helps. "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
You can check for numeric values in a string by using the isNumeric function. You then can format the string as currency with the FormatCurrency function. You could do this validation and formatting in several different places but a real easy way would be to place it in the lostFocus event of the textbox. Below is a simple example:

Private Sub Text1_LostFocus()
If IsNumeric(Text1.Text) = False Then
MsgBox "Non-Numeric Value Entered"
Text1.SetFocus
Else
Text1.Text = FormatCurrency(CCur(Text1.Text), 2)
End If
End Sub

Hope this helps.
 
Missinglinq - the maskededit control is a good idea. It's gong to help me with something that I have been working on for a couple of days. I had forgotten all about it. Thanks for the reminder! 1 Star for you! [2thumbsup] [spidey] [americanflag] [unclesam]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top