Thread: Excel VBA
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Arne[_2_] Arne[_2_] is offline
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
.