Reading TextBox info line by line

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gregory Leck

    Reading TextBox info line by line

    I can import a .txt document into a TextBox

    Each line in the TextBox contains a URL, for example, http://www.whateverdomain.com

    I would like to convert each URL to the following format:
    <a href="http://www.whateverdom ain.com">http://www.whateverdom ain.com</a>

    Obviously I'm a dumb noob. I know how to convert a single line of text but can't figure out how to treat line-by-line, multiple entries in a TextBox.

    Thanks in advance for your suggestions.
  • kimiraikkonen

    #2
    Re: Reading TextBox info line by line

    On Nov 20, 12:02 am, "Gregory Leck" <gregoryl...@vi deotron.cawrote :
    I can import a .txt document into a TextBox
    >
    Each line in the TextBox contains a URL, for example,http://www.whateverdomain.com
    >
    I would like to convert each URL to the following format:
    <a href="http://www.whateverdom ain.com">http://www.whateverdom ain.com</a>
    >
    Obviously I'm a dumb noob. I know how to convert a single line of text but can't figure out how to treat line-by-line, multiple entries in a TextBox..
    >
    Thanks in advance for your suggestions.
    Hi Gregory,
    Textbox control has Lines() property which returns all the lines
    located in textbox. So, you can convert all the lines (lines, which
    represent URLs) using with another array(myurlarr) as follows:

    ' Assuming you have pure URLs line by line in TextBox1
    ' The core of the job
    Dim myurlarr() As String
    myurlarr = TextBox1.Lines
    For x As Integer = 0 To myurlarr.Length - 1
    myurlarr(x) = "<a href=" & """" & TextBox1.Lines( x) & _
    """" & ">" & TextBox1.Lines( x) & "</a>"
    Next


    ' Optionally, you may want to see converted output
    For x As Integer = 0 To myurlarr.Length - 1
    MsgBox(myurlarr (x).ToString)
    Next

    I tested the code that i wrote and i hope it'll work for you,


    Onur Güzel



    Comment

    • James Hahn

      #3
      Re: Reading TextBox info line by line

      For Each S As String In Split(TextBox1. Text, vbCrLf)
      <process S>
      Next

      "Gregory Leck" <gregoryleck@vi deotron.cawrote in message
      news:OPh89JpSJH A.1160@TK2MSFTN GP02.phx.gbl...
      I can import a .txt document into a TextBox

      Each line in the TextBox contains a URL, for example,


      I would like to convert each URL to the following format:
      <a href="http://www.whateverdom ain.com">http://www.whateverdom ain.com</a>

      Obviously I'm a dumb noob. I know how to convert a single line of text but
      can't figure out how to treat line-by-line, multiple entries in a TextBox.

      Thanks in advance for your suggestions.

      Comment

      • Gregory Leck

        #4
        Re: Reading TextBox info line by line

        Thanks for that. It works great. I guess I need to learn more about arrays before I get too ambitious!

        ***
        "Gregory Leck" <gregoryleck@vi deotron.cawrote in message news:OPh89JpSJH A.1160@TK2MSFTN GP02.phx.gbl...
        I can import a .txt document into a TextBox

        Each line in the TextBox contains a URL, for example, http://www.whateverdomain.com

        I would like to convert each URL to the following format:
        <a href="http://www.whateverdom ain.com">http://www.whateverdom ain.com</a>

        Obviously I'm a dumb noob. I know how to convert a single line of text but can't figure out how to treat line-by-line, multiple entries in a TextBox.

        Thanks in advance for your suggestions.

        Comment

        Working...