Results 1 to 3 of 3

Thread: how to get specific string from unpredicted input messages?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    how to get specific string from unpredicted input messages?

    Hi sir, I'm newbie here. I just want your help.
    Let's say, I have these code in my vb:

    Code:
    dim msg1, msg2 as string
    msg1=textbox1.text
    'notes that textbox1 will be inputed with random string but will contain myname: blablabla
    'example
    textbox1.text="newejjdhajdahksjmyname: blablabla asljdsjdksk"
    'or may be inputed like this:
    textbox1.text="asfdssadadamyname: blablabla asadsdasghfhgfhfghfgfhgfgfga"
    msg2 = msg1.find(......i don't know how to coding it)
    textbox2.text="your name: " + msg2
    sorry if I type incorrect english. thanks.

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: how to get specific string from unpredicted input messages?

    Take a look at this
    Code:
            Dim smplText As String = "asfdssadadamyname: blablabla asadsdasghfhgfhfghfgfhgfgfga"
            Dim strToFind As String = "blablabla"
            Dim idx As Integer = smplText.IndexOf(strToFind)
            If idx >= 0 Then
                'string found
            Else
                'not found
            End If
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    Re: how to get specific string from unpredicted input messages?

    Quote Originally Posted by dbasnett View Post
    Take a look at this
    Code:
            Dim smplText As String = "asfdssadadamyname: blablabla asadsdasghfhgfhfghfgfhgfgfga"
            Dim strToFind As String = "blablabla"
            Dim idx As Integer = smplText.IndexOf(strToFind)
            If idx >= 0 Then
                'string found
            Else
                'not found
            End If
    Great suggestion. Thanks a lot sir.

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