ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   textbox codes (https://www.excelbanter.com/excel-programming/376200-textbox-codes.html)

tindatrue

textbox codes
 
i have three TextBoxes
txtPrice,txtQty and txtTotal

i want codes for these textboxes,when a user put the price in txtPrice and
Quantity in txtQty,the txtTotal wil automatically show the the value i.e.
price*Qty=Total
is there anyone who can help me

thanks
--
Neil

Ron de Bruin

textbox codes
 
Try this

Change the names to your TextBox names

With UserForm1
.TextBox3.Text = CDbl(.TextBox1.Text) * _
CDbl(.TextBox2.Text)
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl



"tindatrue" wrote in message ...
i have three TextBoxes
txtPrice,txtQty and txtTotal

i want codes for these textboxes,when a user put the price in txtPrice and
Quantity in txtQty,the txtTotal wil automatically show the the value i.e.
price*Qty=Total
is there anyone who can help me

thanks
--
Neil




Bob Phillips

textbox codes
 
Private Sub txtPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
txtTotal.Text = txtPrice.Text * txtQty.Text
On Error GoTo 0
End Sub

Private Sub txtQty_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
txtTotal.Text = txtPrice.Text * txtQty.Text
On Error GoTo 0
End Sub


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"tindatrue" wrote in message
...
i have three TextBoxes
txtPrice,txtQty and txtTotal

i want codes for these textboxes,when a user put the price in txtPrice and
Quantity in txtQty,the txtTotal wil automatically show the the value i.e.
price*Qty=Total
is there anyone who can help me

thanks
--
Neil




tindatrue

textbox codes
 
Many thanks for your reply,
kindly let me know where to put tese codes, there are many events in
textBox, like change,dblClick etc etc ????
--
aaaaaaaa


"Ron de Bruin" wrote:

Try this

Change the names to your TextBox names

With UserForm1
.TextBox3.Text = CDbl(.TextBox1.Text) * _
CDbl(.TextBox2.Text)
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl



"tindatrue" wrote in message ...
i have three TextBoxes
txtPrice,txtQty and txtTotal

i want codes for these textboxes,when a user put the price in txtPrice and
Quantity in txtQty,the txtTotal wil automatically show the the value i.e.
price*Qty=Total
is there anyone who can help me

thanks
--
Neil





Gary Keramidas

textbox codes
 
and just adding to the bob's suggestion, if you want the total to change on
every number entry without leaving the textbox.

Private Sub txtPrice_Change()
On Error Resume Next
txtTotal.Text = txtPrice.Text * txtQty.Text
On Error GoTo 0

End Sub

Private Sub txtQty_Change()
On Error Resume Next
txtTotal.Text = txtPrice.Text * txtQty.Text
On Error GoTo 0

End Sub

--


Gary


"tindatrue" wrote in message
...
i have three TextBoxes
txtPrice,txtQty and txtTotal

i want codes for these textboxes,when a user put the price in txtPrice and
Quantity in txtQty,the txtTotal wil automatically show the the value i.e.
price*Qty=Total
is there anyone who can help me

thanks
--
Neil




Ron de Bruin

textbox codes
 
See Bob's reply (Exit event)

You see that I use CDbl but in this case it is not needed but if you want to use
textbox1 + testbox2 you must use it

--
Regards Ron de Bruin
http://www.rondebruin.nl



"tindatrue" wrote in message ...
Many thanks for your reply,
kindly let me know where to put tese codes, there are many events in
textBox, like change,dblClick etc etc ????
--
aaaaaaaa


"Ron de Bruin" wrote:

Try this

Change the names to your TextBox names

With UserForm1
.TextBox3.Text = CDbl(.TextBox1.Text) * _
CDbl(.TextBox2.Text)
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl



"tindatrue" wrote in message ...
i have three TextBoxes
txtPrice,txtQty and txtTotal

i want codes for these textboxes,when a user put the price in txtPrice and
Quantity in txtQty,the txtTotal wil automatically show the the value i.e.
price*Qty=Total
is there anyone who can help me

thanks
--
Neil







tindatrue

textbox codes
 
Many Thanks Ron
--
Neil
"tindatrue" wrote:

i have three TextBoxes
txtPrice,txtQty and txtTotal

i want codes for these textboxes,when a user put the price in txtPrice and
Quantity in txtQty,the txtTotal wil automatically show the the value i.e.
price*Qty=Total
is there anyone who can help me

thanks
--
Neil



All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com