|
-
Feb 17th, 2013, 07:01 PM
#1
Thread Starter
Lively Member
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.
-
Feb 17th, 2013, 07:16 PM
#2
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!
-
Feb 17th, 2013, 07:22 PM
#3
Thread Starter
Lively Member
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.
-
Feb 17th, 2013, 07:34 PM
#4
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!
-
Feb 17th, 2013, 07:49 PM
#5
Thread Starter
Lively Member
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.
-
Feb 17th, 2013, 07:59 PM
#6
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!
-
Feb 17th, 2013, 08:07 PM
#7
Thread Starter
Lively Member
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?
-
Feb 17th, 2013, 08:38 PM
#8
Addicted Member
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:
If TextBox1.Text.Contains("(") Then If TextBox1.Text.ToLower.StartsWith("msgbox") Then String1 = TextBox1.Text.Split(""""c)(1) ElseIf TextBox1.Text.Contains("""") Then String1 = TextBox1.Text.Split({"(", ")"}, StringSplitOptions.None)(1) 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|