How to add "+" to positive values in a textfield?

T

Thomas Henke

Hi NG,

how can I add a leading"+" to positive figures in a textfield in a
form? Later I want to calculate further figures with that textfield.
I have tried the following: using "format()" with "+#,##", but then
the textfield is somehow considered as a string.

Example:

F_1 = "+1,500"
F_2 = "+2,000"
Both figures are numerical and based on figures in a subform.
I want to have: F_3 = F_1 + F_2, here "+3,500", but what I get is:
"+1,500+2,000"

Where is the problem?

Regards,
Thomas
 
T

Thomas Henke

Try

F_3 = CLng(F_1) + CLng(F_2)

Thanks, that works!

Now, to complicate that: when furthermore adding a kind of "unit" to
those figures, say "m" for "meter" by using <& " m">, so that F_1 will
be "+1,500 m", CLng will not work any longer. Any help here?

Thomas
 
D

Douglas J. Steele

Thomas Henke said:
Thanks, that works!

Now, to complicate that: when furthermore adding a kind of "unit" to
those figures, say "m" for "meter" by using <& " m">, so that F_1 will
be "+1,500 m", CLng will not work any longer. Any help here?

You should probably reconsider your design.

Typically you'd have a Quantity field (which would be numeric) and a
UnitOfMeasure field (which would be text). Trying to add text fields
together is seldom a good idea (as you've found!)
 
T

Thomas Henke

You should probably reconsider your design.

It is not exactly what I've expected from my query here ;-) but I will
follow your advise. Thanks!

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top