#1
|
|||
|
|||
Word VBA discussion
When using public function in vba I inserted sum formula i.e.
Sum = textbox1.value + textbox2.value When i calculate 1 and 2 it delivers 12 instead of 3 but other symbols such as *,/,- it works correctly. I did hear on internet that + and & used for concatination in vba. So is there a way to use + sign as addition symbol. Please reply. |
#2
|
||||
|
||||
It will work if you tell the code what the values are or the instruction + becomes the default for combining text strings e.g.
Code:
Dim Sum As Long Dim Sum2 As String 'Sum = Val(TextBox1.value) + Val(TextBox2.value) 'or Sum = CLng(TextBox1.value) + CLng(TextBox2.value) Sum2 = TextBox1.value + TextBox2.value MsgBox Sum & vbCr & Sum2
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
What do you mean by what the values are
And how to tell the code . The sample code you replied contains functions such as sum2 or clng which I don't know please reply |
#4
|
|||
|
|||
In the VBA IDE put your cursor on the Val or clng and press the F1 key This will bring up the help page for those key words.
The fact that you haven't already googled 'VBA VAL' or 'VBA CLNG' is pretty disappointing |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
InfoPath - User Permissions & Shared Discussion | rob171171 | Misc | 0 | 09-17-2013 05:14 AM |
other forums with visio discussion | Guy Roth | Visio | 1 | 05-23-2012 05:42 AM |