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 ?
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.

Recommended Answers

All 3 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.