Add two textbox value

PARSA

New Member
Joined
Jan 30, 2014
Messages
44
HI,
WAHT CAN I ADD TWO TEXTBOX VALUE?
I DO THIS CODE:
PHP:
Dim c As Value
Dim D As Value
c = Format(TextBox1.Value, "Number")
D = Format(TextBox2.Value, "Number")
TextBox3.Value = c + D
BUT IT IS WRONG:confused:
CAN YOU HELP ME?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
It's bad form to use all CAPS.

Try something like this...
Code:
    [color=darkblue]If[/color] IsNumeric(TextBox1.Value) And IsNumeric(TextBox2.Value) [color=darkblue]Then[/color]
        TextBox3.Value = [color=darkblue]CSng[/color](TextBox1.Value) + [color=darkblue]CSng[/color](TextBox2.Value)
    [color=darkblue]End[/color] [color=darkblue]If[/color]
 
Upvote 0
There is a lot wrong with the code...

1) In your Dim statement, "Value" is not a valid data type.
2) You are setting c and d "Value" variables to a Format result, which is a text string.
3) "Number" is not a valid predefined format type that can be used with the Format command

Your code would fail for any of these 3 reasons...

If you dimension the variables properly and make valid use of the Format command you can add textboxes values together without too much difficulty.

My response to this thread yesterday is how I would also respond today, if the syntax of your code wasn't so far off:
http://www.mrexcel.com/forum/excel-...ng-userform-textboxes-formatted-currency.html
 
Upvote 0
Actually... item 2) above is fine, in fact, that's what I do on my other response.
But follow the link to the other thread if you want to see how to manage it.
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top