TabControl1.SelectedTab.Controls(4).Text =”Test”

Control and Tab Pages created in runtime. (No of Tab pages depend on user input)

How to handle this control without control Number. ?
(Is any way to handle with Control Name)

If you pay attention to Intellisense when you're typing your code, you'll be able to see that one of the overloaded options is using the name of the control as an index of the control collection

Thanks for Reply, I tried to catch it, still not....
Please show me...

TabControl1.SelectedTab.Controls("TextBox1").Text =”Test”

Sir, Error display while running,

Null Reference Exception was unhandled
Object reference not set to an instance of an object.

In my project,
Tab Pages and controls created(Add) in run time.

If the string you're using doesn't match the name of a control you will get that error.

Sir,
I inserted Text Boxes and Labels as controls to Tab Pages.
I want to change Label.text and Textboxes Text

When you add them give them a name, then use those strings to access them.

Sir, Sorry Iam Not understand it, I'am just start to learn Vb.Net.

I show what I already did,

Declare Controls,
Dim NewMTXT As TextBox
Dim NewMLBL as Label
Dim NewBTN as Button

Before I creating Tab Pages I did like this,
NewMTXT = New TextBox
NewMLBL = New Label
NewBTN = New Button

after I add its,
newPage.Controls.Add(NewMTXT)
newPage.Controls.Add(NewMLBL)

AddHandler NewBTN.Click, AddressOf My1
newPage.Controls.Add(NewBTN)

with "My1" sub,
I want to change "NewMTXT" text, when click "NewBTN"

Sir, Please explain me how to do this,

NewMTXT = New TextBox
NewMTXT.Name = "NewMTXT1"
NewMLBL = New Label
NewMLBL.Name = "NewMLBL1"
NewBTN = New Button

Private Sub My1(sender As Object, e As EventArgs)
    Me.Controls("NewMTXT1").Text = "MyString"
End Sub

Sir,

Thank you very much for your Instructions,
You solved my problem.

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.