Hey,
In my tabcontrol I have a linklabel and textbox made through code.
The goal is to open a url from the textbox by clicking the linklabel
I add the linklabel and textbox:
This is the code that is run when clicking on the linklabelCode:Dim lblLink As New LinkLabel Dim txtLink As New TextBox AddHandler lblLink.Click, AddressOf lblLinkClick lblLink.Text = "Link: " & matchLink.Groups(1).Value txtLink.Text = matchLink.Groups(1).Value
Edit:Code:Private Sub lblLinkClick() Dim txt As TextBox For Each txt In frmMain.TabControl1.SelectedTab.Controls MsgBox(txt.Text) Next When I run the code it highlights the For Each line, and gives this error: Unable to cast object of type 'System.Windows.Forms.Label' to type 'System.Windows.Forms.TextBox'. How can I fix this? End Sub
nevermind, I solved it.
I reaplced to lblLinkClick code to this:
Dim txt As Object
For Each txt In frmMain.TabControl1.SelectedTab.Controls
If TypeOf txt Is TextBox Then
MsgBox(txt.Text)
End If




Reply With Quote