Reputation: 49
I'm creating a document writing program in VB.NET, and I can create multiple tabs. How would I open a file into the textbox that I am open on, even though I can't declare what textbox I'm using? Link to understand this better
Code for the sub:
Public Sub setText(Byval value As String)
If tabPage1.Visible = True Then
mainText.Text = value
ElseIf tabPage2.Visible = True Then
textBox1.Text = value
End If
End Sub
Thanks in advance!
Upvotes: 0
Views: 48
Reputation: 641
You need to use the same type of idea you did for the getText
Dim sub setText(value as string)
Dim mytextbox As TextBox = TabControl1.SelectedTab.Controls.OfType(Of TextBox)().First()
mytextbox.text = value
end sub
Upvotes: 2