Formatting text

Viperchief
09-06-2003, 07:20 AM
Ok, I have 2 textboxes, they arent formatting right, heres the code i have:
Text1(0).Text = Format$(Form1.Text1(0).Text, "$#.00")
Text1(1).Text = Format$(Form1.Text1(1).Text, "$#.00")
They arent wanting to format. They just stay the same

Iceplug
09-06-2003, 07:33 AM
Try putting the Text through a Val() function call...
what kind of stuff do you have in the textboxes?
Text1(0).Text = Format$(Val(Form1.Text1(0).Text), "$#.00")

Viperchief
09-06-2003, 07:34 AM
prices.

Viperchief
09-06-2003, 07:38 AM
That code you had me try gave me an error, I also have another textbox, I got that one to format, but not this one

thingimijig
09-06-2003, 07:51 AM
what about formatcurrency !!!!

Text1(0).Text = Formatcurrency(Form1.Text1(0).Text)


thingimijig.

Viperchief
09-06-2003, 07:53 AM
not defined

thingimijig
09-06-2003, 07:57 AM
Dim something as Currency

Form1.Text1(0).Text = Formatcurrency(something)

Viperchief
09-06-2003, 07:59 AM
invalid procedure call or argument

thingimijig
09-06-2003, 08:01 AM
dont know if you noticed, i edited it, got it the wrong way round

Viperchief
09-06-2003, 08:04 AM
still doesnt work.

John
09-06-2003, 08:22 AM
Works fine for me:
Private Sub cmdFormat_Click()
If Not IsNumeric(txtMoney.Text) Then
MsgBox "Please enter a number", vbCritical, "Numbers Only"
Else
txtFormatted.Text = FormatCurrency(Val(txtMoney.Text), 2)
End If
End Sub
Perhaps there is a different problem, like the wrong name for the text box or something.

Viperchief
09-06-2003, 10:09 AM
nope, still nothing

Iceplug
09-06-2003, 10:57 AM
What version of VB are you using? Does the Format function exist (hint: right-click on it and go to definition)?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum