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: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.
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
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.
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)?