#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Text Boxes

I was following a question, which was posted to this group
about two weeks ago on summing up the values of text boxes
into another text box. I tried the following:

TextboxTotal = T1+T2+T3 'T being the textboxes

instead of adding the numerical values it just places them
side by side. So the contents of Textboxtotal becomes
100200300 instead of 600. However when i did the following
it works:

TextboxTotal = (T1*1)+(T2*1)+(T3*1)

it seems the contents of each box is not being treated as
numbers.

I am using Excel 2000

Is this a bug or I am missing something? Thanks. It is
just bugging me.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Text Boxes

The contents of a textbox is just that, text. So when you write Total.ext =
TextBox1.text + TextBox2.text + TextBox3.text, Excel believes you are asking
for concatenation, just like "Apple" + "Pie" = "Apple Pie".
What you should be doing to get an arithmetic sum is writing Total.Value=
TextBox1.Value+TextBox2.Value+TextBox3.Value

-- Dennis Eisen
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Text Boxes

Hi Dennis,

T1.value+t2.value concatenate the result. I have tried
with text and value. Same result. Anyway, thanks for your
interest and suggestion. Cheers.


-----Original Message-----
The contents of a textbox is just that, text. So when you

write Total.ext =
TextBox1.text + TextBox2.text + TextBox3.text, Excel

believes you are asking
for concatenation, just like "Apple" + "Pie" = "Apple

Pie".
What you should be doing to get an arithmetic sum is

writing Total.Value=
TextBox1.Value+TextBox2.Value+TextBox3.Value

-- Dennis Eisen
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Text Boxes

Hi Jamal,

You can use conversion functions to convert the text strings into numeric
values. Here's an example that will work (assuming your "total" TextBox is
named "TextBox4"):

Private Sub CommandButton1_Click()
Dim dblTotal As Double
Dim ctl As Control

For Each ctl In Controls
If TypeOf ctl Is MSForms.TextBox Then
If ctl.Name < "TextBox4" Then
If IsNumeric(ctl.Object.Text) Then
dblTotal = dblTotal + _
CDbl(ctl.Object.Text)
End If
End If
End If
Next ctl

TextBox4.Text = Format$(dblTotal, "#,##0.00")
End Sub


This will add up all values in TextBoxes on the Userform. It ignores
non-numeric values.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Jamal wrote:
I was following a question, which was posted to this group
about two weeks ago on summing up the values of text boxes
into another text box. I tried the following:

TextboxTotal = T1+T2+T3 'T being the textboxes

instead of adding the numerical values it just places them
side by side. So the contents of Textboxtotal becomes
100200300 instead of 600. However when i did the following
it works:

TextboxTotal = (T1*1)+(T2*1)+(T3*1)

it seems the contents of each box is not being treated as
numbers.

I am using Excel 2000

Is this a bug or I am missing something? Thanks. It is
just bugging me.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default font for pasted text in text boxes - Excel 2007 MS OFFICE USER EIT Excel Discussion (Misc queries) 0 March 25th 10 09:01 PM
User Form Text Boxes - Copy format of text boxes NDBC Excel Discussion (Misc queries) 3 July 2nd 09 02:02 AM
How to Import Visio Text Boxes into Excel as Text Nick_adminator Excel Discussion (Misc queries) 2 December 12th 07 05:56 AM
How do I link Text Boxes to Cells, not Cells to Text Boxes? Ebby Excel Worksheet Functions 1 May 15th 07 11:31 PM
In Excel, option to enter text in cells the same as text boxes RobGMU Excel Worksheet Functions 0 October 26th 05 04:20 PM


All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"