Results 1 to 2 of 2

Thread: [RESOLVED] Can't show text from textbox

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2009
    Posts
    203

    Resolved [RESOLVED] Can't show text from textbox

    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:

    Code:
    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
    This is the code that is run when clicking on the linklabel

    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
    Edit:
    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
    Last edited by vixez; Mar 27th, 2010 at 05:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width