I am trying to figure out how to make a form quicker to fill out for my work, and it involves having a employee enter a patient's name in one text box, and then having that information duplicated in all other name text boxes. Here's what I'm thinking....

function FillName(f) {
 {
    f.FillNameBox1.value = f.wholename.value;
    f.FillNameBox2.value = f.wholename.value;
  }
}

Silly question - why not just have one field on the form for "name"? What possible reason is there to have it more than once if you are just going to replicate it?

But if you must you can have a look at the following code. I created a form with five textboxes. Editing the text in any textbox automatically applies those changes to the remaining textboxes. In your case you will have other textboxes on your form that you do not want to link in this way. You could, as a suggestion, put a special value in the Tag property so that only textboxes with "Name", for example, in the Tag property are modified. My original example is

Public Class Form1

    Private Sub TextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged, TextBox4.TextChanged, TextBox5.TextChanged

        For Each ctrl As TextBox In Me.Controls.OfType(Of TextBox)()
            If Not ctrl Is sender Then
                ctrl.Text = sender.text
            End If
        Next

    End Sub

End Class

If you modify the test to

If Not ctrl Is sender And ctrl.Tag = "Name" Then

then you can restrict the replication to only specific textboxes.

You may like to investigate the defaultValue property for the other name text boxes. When they enter the name in f.wholename set

f.FillNameBox1.defaultvalue = f.wholename.value

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.