Results 1 to 8 of 8

Thread: Get text from inside two symbols.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Posts
    70

    Get text from inside two symbols.

    Ok, so lets say I have a textbox(Textbox1) and a button.

    If the user inputs the text into the textbox: MsgBox "THIS IS MY MESSAGE"

    I want that when the Button is pressed, only the text (THIS IS MY MESSAGE) is displayed.

    Also, how would you do that if the user inputted into the textbox: MsgBox (THIS IS MY MESSAGE)

    Using parenthesis instead of Quotation marks.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Get text from inside two symbols.

    Is this the only content of the textbox, one line among many, found anywhere in a longer text? Do you want to register syntax errors or are you content with any old delimiter? What is the ultimate aim here.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Posts
    70

    Re: Get text from inside two symbols.

    It is in a one line textbox. If the user enters into the textbox: Msgbox "Any text here" I want to be able to take the text from the quotes, and put it in a variable for later use. I.e whatever text was in the quotation marks was put in the variable String1.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Get text from inside two symbols.

    Well, the very basic bones ...


    If TextBox1.Text.ToLower.StartsWith("msgbox") Then
    String1 = TextBox1.Text.Split(""""c)(1)
    End If
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Posts
    70

    Re: Get text from inside two symbols.

    Thanks, this worked! Also, how would I go about doing this if I used parenthesis around the text I.e. Msgbox (Any text here) . Thanks! And is this possible in a multiline textbox?
    Last edited by theryan722; Feb 17th, 2013 at 07:59 PM.

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Get text from inside two symbols.

    String1 = TextBox1.Text.Split({"(", ")"}, StringSplitOptions.None)(1)
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2012
    Posts
    70

    Re: Get text from inside two symbols.

    How would I do this for both scenarios (the text is surrounded by quoation marks or parenthesis) in a multiline textbox? Is that even possible?

  8. #8
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    Re: Get text from inside two symbols.

    Maybe this will do it, dunno, am just adding a check for any of the scenarios using the 2 sample codes given above from dunfiddlin.

    vb.net Code:
    1. If TextBox1.Text.Contains("(") Then
    2.       If TextBox1.Text.ToLower.StartsWith("msgbox") Then String1 = TextBox1.Text.Split(""""c)(1)
    3. ElseIf TextBox1.Text.Contains("""") Then
    4.       String1 = TextBox1.Text.Split({"(", ")"}, StringSplitOptions.None)(1)
    5. End If

Tags for this Thread

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