Todd,
Something like this maybe?
Private Sub CommandButton1_Click()
Dim curTemp As Currency
curTemp = 0
If Not CBool(InStr(1, OrderForm.TextBox19.Value, "Select")) Then curTemp
= curTemp + CCur(OrderForm.TextBox19.Value)
If Not CBool(InStr(1, OrderForm.TextBox24.Value, "Select")) Then curTemp
= curTemp + CCur(OrderForm.TextBox24.Value)
...
OrderForm.TextBox119.Value = Format(curTemp, "Currency")
End Sub
Rob
"Todd Huttenstine" wrote in message
...
Here is what I did and now no number is poping up in TextBox119 at all.
Sub CalculateProfit()
Dim curTemp As Currency
curTemp = CCur(OrderForm.TextBox9.Value) + CCur(OrderForm.TextBox14.Value)
+
_
CCur(OrderForm.TextBox19.Value) + CCur(OrderForm.TextBox24.Value) + _
CCur(OrderForm.TextBox29.Value) + CCur(OrderForm.TextBox34.Value) + _
CCur(OrderForm.TextBox39.Value) + CCur(OrderForm.TextBox44.Value) + _
CCur(OrderForm.TextBox49.Value) + CCur(OrderForm.TextBox54.Value) + _
CCur(OrderForm.TextBox59.Value) + CCur(OrderForm.TextBox64.Value) + _
CCur(OrderForm.TextBox69.Value) + CCur(OrderForm.TextBox74.Value) + _
CCur(OrderForm.TextBox79.Value) + CCur(OrderForm.TextBox84.Value) + _
CCur(OrderForm.TextBox89.Value) + CCur(OrderForm.TextBox94.Value) + _
CCur(OrderForm.TextBox99.Value) + CCur(OrderForm.TextBox104.Value) + _
CCur(OrderForm.TextBox109.Value) + CCur(OrderForm.TextBox114.Value)
OrderForm.TextBox119.Value = Replace(curTemp, "Select", "")
End Sub
"Rob van Gelder" wrote in message
...
Looks like the + operator in this case is acting as a string
concatenator
instead of an addition.
Because the $ is in front of the text, it's treating them all as
strings.
You could wrap each with a CCur() function. eg.
CCur(OrderForm.TextBox9.Value) + CCur( ...
Sub CalculateProfit()
Dim curTemp As Currency
curTemp = CCur("$30") + CCur("$40") + CCur("$50")
End Sub
Because of the way VB does datatype conversions, only the first CCur()
is
needed, but to be 100% sure, specify them all. It's generally considered
bad
programming practise to rely on auto datatype conversions. It holds true
for
Date datatypes especially.
Rob
"Todd Huttenstine" wrote in message
...
Hey Rob, this is your code
I have 22 Product Types. You select the product from the ComboBox.
When
you select the product, all the textboxes auto populate. Each product
has
3
textboxes. One is Number of Units, next is Unit Cost, next is Unit
Sale.
Every product has these textboxes and these 3 text boxes have direct
impact
over profit. In each of these 3 textbox change events I put the code
CalculateProfit so it will call that procedure from the module. The
module
contains this code below. My problem is when I select multiple
products,
textbox 119 does not add the textboxes up, it just keeps adding the
price
into the textbox. For example, one product I select has a profit of
$30,
the next has a profit of $40, instead of textbox 119 displaying $80,
it
displays $30$40. This pattern continues. Why is this happening? Is
it
happening because the code is in the change event for each product so
the
code calculates it up individual? I would like for it to add it so
$80
displays.
Sub CalculateProfit()
Dim strTemp as String
strTemp = OrderForm.TextBox9.Value + OrderForm.TextBox14.Value +
OrderForm.TextBox19.Value + OrderForm.TextBox24.Value + _
OrderForm.TextBox29.Value + OrderForm.TextBox34.Value +
OrderForm.TextBox39.Value + OrderForm.TextBox44.Value + _
OrderForm.TextBox49.Value + OrderForm.TextBox54.Value +
OrderForm.TextBox59.Value + OrderForm.TextBox64.Value + _
OrderForm.TextBox69.Value + OrderForm.TextBox74.Value +
OrderForm.TextBox79.Value + OrderForm.TextBox84.Value + _
OrderForm.TextBox89.Value + OrderForm.TextBox94.Value +
OrderForm.TextBox99.Value + OrderForm.TextBox104.Value + _
OrderForm.TextBox109.Value + OrderForm.TextBox114.Value
OrderForm.TextBox119.Value = Replace(strTemp, "Select", "")
End Sub