Need value of a textbox

I have the following piece of code.

Dim offPlayer as Integer
TextBox39.Text = "txtHome" & offPlayer & ".text"

In my example, offPlayer is 8. I would like textBox39.Text = txtHome8.text. It currently puts in the string "txtHome8.text" and not the value.

Please help.

Thanks,
Doug



Answer this question

Need value of a textbox

  • Blast

    Looks like you're missing a "y" in offPlaer... Be sure that you actually have a TextBox control on the form that is named txtHome8 when offPlayer is 8.


  • Han Qiao

    Thank you for the suggestion, however, it is giving me an error NullReferenceException was handled "Object reference not set to an instance of an object"

    TextBox54.Text = Me.Controls("txtHome" + offPlaer).Text

    The message points to "txtHome"


  • Paarul

    I think you're asking for this:
    TextBox39.Text = Me.Controls("txtHome" & offPlayer).Text


  • Need value of a textbox