Bruce Stradling was telling us: Bruce Stradling nous racontait que :
[Quoted Text] > I wanted to calculate a text field based on the falues of 3 other text > fileds. > > The problem arose that when I did this: > > FieldA.Value=800.00 > FieldB.Value=200.00 > FieldA.Value=.00 > FieldD.Value = FormatNumber(FieldA.Value + FieldB.Value + > FieldB.Value, 2) > I got a text value of 800.00200.00.00 > > How do I define a numeric field in a userform instead of using a text > field?
You are concatenating strings with your code. You know that FieldA.Value is in fact a number, but as far as the compiler is concerned, it is a string.
It is always better to do your own data-conversion in your code then to let the compiler do it for you...
Try something like:
FieldD.Value = CStr(FormatNumber(Val(FieldA.Value) + _ Val(FieldB.Value) + Val(FieldC.Value), 2))
-- Salut! _______________________________________ Jean-Guy Marcil - Word MVP jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO Word MVP site: http://www.word.mvps.org
|