Userforms - Display result of a calculation in a textbox
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim dblCost as Double, dblPrice as Double
if len(trim(textbox1.text)) 0 and len(trim(textbox2.text)) 0 then
if isnumeric(textbox1.text) and isnumeric(textbox2.text) then
dblCost = cdbl(textbox1.text)
dblPrice = cdbl(textbox2.text)
if dblPrice < 0 then
Textbox3.Text = Format(dblPrice-dblCost,"#,##0.00") & " - " & _
Format((dblPrice-dblCost)/dblPrice,"0.00%")
end if
end if
end if
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim dblCost as Double, dblPrice as Double
if len(trim(textbox1.text)) 0 and len(trim(textbox2.text)) 0 then
if isnumeric(textbox1.text) and isnumeric(textbox2.text) then
dblCost = cdbl(textbox1.text)
dblPrice = cdbl(textbox2.text)
if dblPrice < 0 then
Textbox3.Text = Format(dblPrice-dblCost,"#,##0.00") & " - " & _
Format((dblPrice-dblCost)/dblPrice,"0.00%")
end if
end if
end if
End Sub
--
Regards,
Tom Ogilvy
Gary Hall wrote in message
...
I am creating a ueserform that shows asks the user to
enter a cost price and a selling price for an item.
Is ther a way of having another box (textbox?)which will
show the result of a calculation based upon the two
figures entered e.g Profit made in absolute and
percentage terms.
Thanks for your help
|