#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Excel VBA

Hello,

I have a problem. When I try total up values fom a list
of textboxes using the formula as below, it actually
combine the values from all the textboxes.
__________________________________________________ _______
txtFinalBill.Text = Val(txtCalculatedDemandCharge.Text) +
Val(txtEmp.Text) + Val(txtEmop.Text) + Val
(txtFirmStandbyCharge.Text) + Val
(txtNonFirmStandbyCharge.Text) + Val
(txtPowerFactorPenalty.Text) + Val(TextBox25.Text)
__________________________________________________ ________

Has it got its limitation in totalling up the values?

Thanks,

Sheela
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Excel VBA

It is strange to assign a numeric value to a string
(textbox.text is of type string). On the other hand, the
textbox also has a property called 'value' which will
return a variant, and which will, in principle need no
explicit conversions.

The problem with adding the variants textbox.value of all
textboxes is, that it will add the strings instead of the
numbers. So first, tell VBA what kind of addition is
required, and then actually carry it out:

Dim dblTmp As Double
dblTmp = TextBox1.Value
TextBox5.Value = dblTmp + TextBox2.Value + TextBox3.Value
+ TextBox4.Value

Agreed, you need one extra temporary variable, but you do
not have any conversions

-----Original Message-----
Hello,

I have a problem. When I try total up values fom a list
of textboxes using the formula as below, it actually
combine the values from all the textboxes.
_________________________________________________ ________
txtFinalBill.Text = Val(txtCalculatedDemandCharge.Text) +
Val(txtEmp.Text) + Val(txtEmop.Text) + Val
(txtFirmStandbyCharge.Text) + Val
(txtNonFirmStandbyCharge.Text) + Val
(txtPowerFactorPenalty.Text) + Val(TextBox25.Text)
_________________________________________________ _________

Has it got its limitation in totalling up the values?

Thanks,

Sheela
.

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



All times are GMT +1. The time now is 12:21 AM.

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

About Us

"It's about Microsoft Excel"