View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Patrick C. Simonds Patrick C. Simonds is offline
external usenet poster
 
Posts: 343
Default Problem adding the values of 2 TextBoxes

Thanks Gary

But of course my problems continue. The full line of code is below, and my
problem is that if any one of those TextBoxes is blank, I get a Type
Mismatch error. I am trying to avoid using helper cells on the worksheet.

Any ideas on how I can get it to ignore blank TextBoxes?





TextBox1.Value = CDbl(TextBox13.Value) + CDbl(TextBox23.Value) +
CDbl(TextBox33.Value) + CDbl(TextBox43.Value) + CDbl(TextBox53.Value) +
CDbl(TextBox63.Value) + CDbl(TextBox14.Value) + CDbl(TextBox24.Value) +
CDbl(TextBox34.Value) + CDbl(TextBox44.Value) + CDbl(TextBox54.Value) +
CDbl(TextBox64.Value)


"Gary Keramidas" wrote in message
...
sorry, don't know what I was thinking

CDbl(Me.TextBox2.Value) + CDbl(Me.TextBox1.Value)

--


Gary K



"Patrick C. Simonds" wrote in message
...
Can anyone tell me why these do not add together?

TextBox1 = TextBox13.Value + TextBox23.Value

Lets say the value of TextBox13 is 53 and the value of TextBox23 is 10.
Instead of returning 63 I get 5310.



Below is the code that generates the value of TextBox13

TextBox13.Value = (TimeValue(TextBox12.Value) -
TimeValue(TextBox11.Value)) * 24
TextBox13.Value = Format(TextBox13.Value, "0.0000")



TextBox12 value is entered by the user as a time without the : such as
1843 for 6:43 pm and then converted to the correct format by the code
below


Private Sub TextBox12_AfterUpdate()

TextBox12.Value = Format(Application.Text(Replace(TextBox12.Value,
":", ""), "00\:00"), "hh:mm")

End Sub