ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   add numbers in textboxes on userform (https://www.excelbanter.com/excel-programming/277339-add-numbers-textboxes-userform.html)

KimberlyC

add numbers in textboxes on userform
 
Hi!

I have textbox1, textbox2, textbox3, textbox4, and textbox5 on a userform.
I'm trying to add textbox1, textbox2, textbox3, and textbox4 and place the
sum (total) in Textbox5.
I've tried the following code attached to a command button:
me.textbox 5= (textbox1 + textbox2+ textbox3 + textbox4)

I keep getting the error message that textbox4 member or data cannot be
found. I've double check the spelling of the names and they are correct. If
I remove Textbox4 from the code, then the error states it cannot find
textbox3 member or data.

What am I doing wrong??

Thanks in advance for your help!!!

Kimberly



John Wilson

add numbers in textboxes on userform
 
Kimberly,

What's in the textboxes is a string.
You have to convert them to numbers before adding them.

e.g.
me.textbox5= cDbl(textbox1) + cDbl(textbox2)
etc.

John

KimberlyC wrote:

Hi!

I have textbox1, textbox2, textbox3, textbox4, and textbox5 on a userform.
I'm trying to add textbox1, textbox2, textbox3, and textbox4 and place the
sum (total) in Textbox5.
I've tried the following code attached to a command button:
me.textbox 5= (textbox1 + textbox2+ textbox3 + textbox4)

I keep getting the error message that textbox4 member or data cannot be
found. I've double check the spelling of the names and they are correct. If
I remove Textbox4 from the code, then the error states it cannot find
textbox3 member or data.

What am I doing wrong??

Thanks in advance for your help!!!

Kimberly



KimberlyC

add numbers in textboxes on userform
 
Hi
Thanks!
I tried it and I'm still getting the same error messages.
Is there anything else that could casue these errors?

Thanks again!!

"John Wilson" wrote in message
...
Kimberly,

What's in the textboxes is a string.
You have to convert them to numbers before adding them.

e.g.
me.textbox5= cDbl(textbox1) + cDbl(textbox2)
etc.

John

KimberlyC wrote:

Hi!

I have textbox1, textbox2, textbox3, textbox4, and textbox5 on a

userform.
I'm trying to add textbox1, textbox2, textbox3, and textbox4 and place

the
sum (total) in Textbox5.
I've tried the following code attached to a command button:
me.textbox 5= (textbox1 + textbox2+ textbox3 + textbox4)

I keep getting the error message that textbox4 member or data cannot be
found. I've double check the spelling of the names and they are correct.

If
I remove Textbox4 from the code, then the error states it cannot find
textbox3 member or data.

What am I doing wrong??

Thanks in advance for your help!!!

Kimberly





John Wilson

add numbers in textboxes on userform
 
Kimberly,

If the textboxes do exist, they should be listed in the dropdown
in the VBA Editor.
If they don't, try to compile the project and save, close, reopen
the workbook.


John

"KimberlyC" wrote in message
...
Hi
Thanks!
I tried it and I'm still getting the same error messages.
Is there anything else that could casue these errors?

Thanks again!!

"John Wilson" wrote in message
...
Kimberly,

What's in the textboxes is a string.
You have to convert them to numbers before adding them.

e.g.
me.textbox5= cDbl(textbox1) + cDbl(textbox2)
etc.

John

KimberlyC wrote:

Hi!

I have textbox1, textbox2, textbox3, textbox4, and textbox5 on a

userform.
I'm trying to add textbox1, textbox2, textbox3, and textbox4 and

place
the
sum (total) in Textbox5.
I've tried the following code attached to a command button:
me.textbox 5= (textbox1 + textbox2+ textbox3 + textbox4)

I keep getting the error message that textbox4 member or data cannot

be
found. I've double check the spelling of the names and they are

correct.
If
I remove Textbox4 from the code, then the error states it cannot find
textbox3 member or data.

What am I doing wrong??

Thanks in advance for your help!!!

Kimberly







KimberlyC

add numbers in textboxes on userform
 
Thanks John
I just needed to close and reopen. It's working now.
Thanks again!
"John Wilson" wrote in message
...
Kimberly,

If the textboxes do exist, they should be listed in the dropdown
in the VBA Editor.
If they don't, try to compile the project and save, close, reopen
the workbook.


John

"KimberlyC" wrote in message
...
Hi
Thanks!
I tried it and I'm still getting the same error messages.
Is there anything else that could casue these errors?

Thanks again!!

"John Wilson" wrote in message
...
Kimberly,

What's in the textboxes is a string.
You have to convert them to numbers before adding them.

e.g.
me.textbox5= cDbl(textbox1) + cDbl(textbox2)
etc.

John

KimberlyC wrote:

Hi!

I have textbox1, textbox2, textbox3, textbox4, and textbox5 on a

userform.
I'm trying to add textbox1, textbox2, textbox3, and textbox4 and

place
the
sum (total) in Textbox5.
I've tried the following code attached to a command button:
me.textbox 5= (textbox1 + textbox2+ textbox3 + textbox4)

I keep getting the error message that textbox4 member or data cannot

be
found. I've double check the spelling of the names and they are

correct.
If
I remove Textbox4 from the code, then the error states it cannot

find
textbox3 member or data.

What am I doing wrong??

Thanks in advance for your help!!!

Kimberly








John Wilson

add numbers in textboxes on userform
 
Kimberly,

I just needed to close and reopen. It's working now.

I'm glad that solved your problem, but..........
When you add a textbox (or other control) to a UserForm
it should "automatically" be included in your "project" without
having to close and reopen.
Sometimes this doesn't happen and I can't give you an answer
as to why. I've asked why in the ng's and can't really get
a definitive answer myself, but it does happen.
Anyway.....since this did occur in the particular workbook
that you're using, if you haven't already done so, do yourself
a favor and dowload Rob Bovey's "Code Cleaner".
http://www.appspro.com/
and use it religiously (at least on this workbook).

John


"KimberlyC" wrote in message
...
Thanks John
I just needed to close and reopen. It's working now.
Thanks again!
"John Wilson" wrote in message
...
Kimberly,

If the textboxes do exist, they should be listed in the dropdown
in the VBA Editor.
If they don't, try to compile the project and save, close, reopen
the workbook.


John

"KimberlyC" wrote in message
...
Hi
Thanks!
I tried it and I'm still getting the same error messages.
Is there anything else that could casue these errors?

Thanks again!!

"John Wilson" wrote in message
...
Kimberly,

What's in the textboxes is a string.
You have to convert them to numbers before adding them.

e.g.
me.textbox5= cDbl(textbox1) + cDbl(textbox2)
etc.

John

KimberlyC wrote:

Hi!

I have textbox1, textbox2, textbox3, textbox4, and textbox5 on a
userform.
I'm trying to add textbox1, textbox2, textbox3, and textbox4 and

place
the
sum (total) in Textbox5.
I've tried the following code attached to a command button:
me.textbox 5= (textbox1 + textbox2+ textbox3 + textbox4)

I keep getting the error message that textbox4 member or data

cannot
be
found. I've double check the spelling of the names and they are

correct.
If
I remove Textbox4 from the code, then the error states it cannot

find
textbox3 member or data.

What am I doing wrong??

Thanks in advance for your help!!!

Kimberly











All times are GMT +1. The time now is 08:25 AM.

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