Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
calculate vba userform type mismatch when decimal is entered
I have a vba userform that I want to calculate fields.
I have a quantity, unit price, and want the calculation to be in the extended price field. I'm using the following code, and it works great, as long as you use a number not starting with a decimal. ie.. I can input 1 x 1.50 and it works, or I can enter 1 x 0.50 and it works, but if I enter 1 x .5 it errors out as a type mismatch. What am I doing wrong? Thank you Private Sub Txtitemunit1_Change() If Me.TxtItemQty1.Value < "" Then Me.TxtItemExt1.Value = Me.TxtItemUnit1.Value * Me.TxtItemQty1.Value End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
calculate vba userform type mismatch when decimal is entered
The problem lies with the empty box which is text, text * value = Error !!
so try the following to force values .... Me.TxtItemExt1.Value = Val(Me.TxtItemUnit1.Value) * Val(Me.TxtItemQty1.Value) -- Regards, Nigel "Pam" wrote in message ... I have a vba userform that I want to calculate fields. I have a quantity, unit price, and want the calculation to be in the extended price field. I'm using the following code, and it works great, as long as you use a number not starting with a decimal. ie.. I can input 1 x 1.50 and it works, or I can enter 1 x 0.50 and it works, but if I enter 1 x .5 it errors out as a type mismatch. What am I doing wrong? Thank you Private Sub Txtitemunit1_Change() If Me.TxtItemQty1.Value < "" Then Me.TxtItemExt1.Value = Me.TxtItemUnit1.Value * Me.TxtItemQty1.Value End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to type format time in decimal format & calculate | Excel Discussion (Misc queries) | |||
Type Mismatch: array or user defined type expected | Excel Programming | |||
How to calculate time in 1/100 decimal while it is entered 1/60 | Excel Programming | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming | |||
Passing Userform Listbox to sub causes type-mismatch error | Excel Programming |