ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SUM in Userform (https://www.excelbanter.com/excel-programming/398546-sum-userform.html)

excelent

SUM in Userform
 
Hi Experts
Using Excel 2003

What is the right way to SUM 2 TextBoxes ?

I got a Userfom with 3 Textboxes:

TboxBread ( value is 5.50 )
TboxButter ( value is 4.50 )
TboxSUM ( value has to be 10.00 )

Why the h... isent there a Valuebox to use instead of Textbox ?

any help is velcome.

Keithlo

SUM in Userform
 
Try using the Val function for the values in your text boxes, as in this
snippet:

Private Sub CommandButton1_Click()
Dim My1, My2, My3
My1 = Val(UserForm1.TextBox1.Value)
My2 = Val(UserForm1.TextBox2.Value)
My3 = My1 + My2
UserForm1.TextBox3.Value = My3
End Sub

Hope this helps.

Keith

"excelent" wrote:

Hi Experts
Using Excel 2003

What is the right way to SUM 2 TextBoxes ?

I got a Userfom with 3 Textboxes:

TboxBread ( value is 5.50 )
TboxButter ( value is 4.50 )
TboxSUM ( value has to be 10.00 )

Why the h... isent there a Valuebox to use instead of Textbox ?

any help is velcome.


Tom Ogilvy

SUM in Userform
 
TboxSum.Value = Val(TboxBread.Value) + Val(TboxButter.Value)

--
Regards,
Tom Ogilvy


"excelent" wrote:

Hi Experts
Using Excel 2003

What is the right way to SUM 2 TextBoxes ?

I got a Userfom with 3 Textboxes:

TboxBread ( value is 5.50 )
TboxButter ( value is 4.50 )
TboxSUM ( value has to be 10.00 )

Why the h... isent there a Valuebox to use instead of Textbox ?

any help is velcome.


excelent

SUM in Userform
 
ok that would do the trick :-)

thanks both Keithlo and Tom


"Tom Ogilvy" skrev:

TboxSum.Value = Val(TboxBread.Value) + Val(TboxButter.Value)

--
Regards,
Tom Ogilvy


"excelent" wrote:

Hi Experts
Using Excel 2003

What is the right way to SUM 2 TextBoxes ?

I got a Userfom with 3 Textboxes:

TboxBread ( value is 5.50 )
TboxButter ( value is 4.50 )
TboxSUM ( value has to be 10.00 )

Why the h... isent there a Valuebox to use instead of Textbox ?

any help is velcome.



All times are GMT +1. The time now is 12:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com