i am doing a school project which basically deals with forms and an access database.I have various textboxes in a form.I want some textboxes to be filled automatically with a value when another textbox has been filled.

For e.g , if the user fills in the 'Cost' textbox , 'Total amount' should be same as the value the user just entered in Cost.Of course the value in 'Total amount' should be displayed as soon as the user moves to the next textbox, without haveving to clcik on any button 

How can this be done in vb.net ?
Ignore any validation whatsoever i just need to understand how its done

Sorry for putting this as code snippet but i keep getting

The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or curly braces.

4 Years
Discussion Span
Last Post by Khav

Use the Leave event in the first textbox as in

Private Sub TextBox1_Leave(sender As Object, e As System.EventArgs) Handles TextBox1.Leave
    TextBox2.Text = TextBox1.Text
    TextBox3.Text = TextBox1.Text
End Sub

This code will be executed as soon as the user leaves the TextBox1 control.


you can also use textbox text change event for this ,here is an example to in which we have to give qty and price and nettotal will calculated auto.

'use this code on the price textbox's text change event

txtNetTotal.text =val( txtQty.text) * val( txtPrice.text)

Thanks to both of you
Reverend Jim code snippet worked perfectly

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.