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

auto - Format values txt 1

Status
Not open for further replies.

jajinder

Technical User
Mar 11, 2004
88
NL
Hi...

Got me a form with several txt's. The user is allowed to enter a value (numbers only). If one fills 5000 in a txt, the value in the txt should be, for instance, 5000,00.

I tried Me.txtBla = format(txtBla, "0,00") (and several other) But it does not work.

Someone has a solution? Perhaps a link where I can find more info. (MSDN not!!)

Please be patient, thirth day I'm working with VB.

---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
 
Well... First off the format function is wrong. Should be.

txtBla = Format(txtBla, "#,###.00")



Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Thnx Casper.. ;) This worx..

But now something really weird is going on????
When, for example, I try to enter 25 in the txt the cursor moves one to the left so it says 52,00 (8o)

Did I do something wrong?

---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
 
Aha...

When the comma (,) appears the cursor (auto)moves to the left.

---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
 
Ohhhh You are trying to change the text as you type...

I have a good function for this at home, but maybe someone here has a function available now.

Anyone have an InStr function to move the cursor to the proper position on KeyPress?

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Thnx in advanced Casper... My weekend is starting. See ya next week perhaps?

---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
 
Anyone??? Please..., Or perhaps someone has a link where I can find documentation about formatting and InStr-functions?

---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
 
Here's a start....

I had a better algorythm that uses the SelStart property and the callback to set the right position. But starting I can't find it.

Private Sub Text1_Change()
Dim iPos As Integer

Text1 = Format(Text1, "#,###.00")
iPos = InStr(1, Text1, ".")
If iPos > 0 Then
Text1.SelStart = iPos - 1
Else
Text1.SelStart = iPos
End If
End Sub



Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Thx man... Have a shiny one...

---------------------------------------
This will be the day when all of God’s children will be able to sing with a new meaning, “My country, ‘tis of thee, sweet land of liberty, of thee I sing. Land where my fathers died, land of the pilgrim’s pride, from every mountainside, let freedom ring. - Marten Luther King
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top