|
-
Oct 28th, 2000, 12:33 AM
#1
Thread Starter
Lively Member
When I add the value of two txt fields (I should say numerical fields), I'm getting a wierd concatenation of the two varibles. I just want it to simply add the two values together! Here's what I found in the MSDN Database:
+ Operator Example
This example uses the + operator to sum numbers. The + operator can also be used to concatenate strings. However, to eliminate ambiguity, you should use the & operator instead. If the components of an expression created with the + operator include both strings and numerics, the arithmetic result is assigned. If the components are exclusively strings, the strings are concatenated.
Code:
Dim MyNumber, Var1, Var2
MyNumber = 2 + 2 ' Returns 4.
MyNumber = 4257.04 + 98112 ' Returns 102369.04.
Var1 = "34": Var2 = 6 ' Initialize mixed variables.
MyNumber = Var1 + Var2 ' Returns 40.
Var1 = "34": Var2 = "6" ' Initialize variables with strings.
MyNumber = Var1 + Var2 ' Returns "346" (string concatenation).
NOW...I'll be more specific about my problem:
Here's the code
Code:
txtTotal.Value = (txtPDA9.Value + txtPDAO1.Value)
txtTotal.Value = Format(txtTotal, "$#,##0")
'Format for first variable is = Format(txtPDA9, "$#,##0")
'"$#,##0" is the same format for txtPDAO1.Value
If txtPDA9.Value is = $2,000 and txtPDAO1.Value is = $3,432
I am getting a return value of $2,003,432
In addition, I have tried several approaches and tactics to correct this with no luck...Can I disable the concatenation? I know that I can enable it with the & operator. Is this problem arising from the way that the fields are initialized? Please help.
Cordially,
Flint Puckett, MBA
J&J
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|