Can't format number

BJS

Registered User.
Local time
Today, 06:28
Joined
Aug 29, 2002
Messages
109
Hello,

I have a text box on a form that displays the result of a calculation.

My numbers are strings, converted to double during the calculation.
once converted to double, I cannot get my text box on the form to display the result using the format function.

Dim strNum1 as string
Dim strNum2 as string

strNum1 = 123.25
strNum2 = 321.25


strNum2 = Cdbl(strNum1) * Cdbl(strNum2)
Me.txtResult = Format(strNum2, "0.#######")

My result before formatting is 39594.0625
My result with formatting should be: 39594.062 (it must display 8 numbers)

When using FormatNumber(strNum2, "0.#######"), I get this error message:
Cast from string "0.#######" to type 'Integer' is not valid.

When using Format(strNum2, "0.#######"):
My text box displays: "0.#######"

PLEASE HELP! :confused:
 
Pat Hartman said:
Why would you ever dim numeric values that you need to use in calculations as strings? Go back to square 1 and redim the variables as single (unless you really need them to be double) and ditch the conversion functions.

Pat, I reverted to dimensioning my variables as strings, due to another problem I had, which was trying to display 9.09. See my post "Trouble displaying 0" on 26 Feb 04.

If I redim them as single, will I not have the same problem whereby the numbers containing "0" will not display properly?
 

Users who are viewing this thread

Back
Top Bottom