Results 1 to 6 of 6

Thread: Get char between "[" and "]" [Resolved]

  1. #1

    Thread Starter
    Addicted Member g-mie's Avatar
    Join Date
    Jan 2004
    Location
    EarTh
    Posts
    212

    Resolved Get char between "[" and "]" [Resolved]

    Hello Gurus..

    How to get any char between "[" and "]" in TextBox1.Text?
    Then transfer it into TextBox2.Text.

    Thank You









    Added green "resolved" checkmark - Hack
    Last edited by Hack; Dec 20th, 2005 at 07:38 AM.

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Get char between "[" and "]"

    Hi,

    Insert a new form with two text box control and a command button and paste the following code in the code window:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim intStart As Integer
    3. Dim intEnd As Integer
    4. intStart = InStr(1, Text1.Text, "[", vbTextCompare)
    5. intEnd = InStr(1, Text1.Text, "]", vbTextCompare)
    6. Text2.Text = Mid$(Text1.Text, intStart + 1, intEnd - intStart - 1)
    7. End Sub
    CS

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Get char between "[" and "]"

    VB Code:
    1. Dim intLeft As Integer
    2. Dim intRight As Integer
    3.  
    4. intLeft = InStr(Text1.Text, "[")
    5. intRight = InStrRev(Text1.Text, "]")
    6. Text2.Text = Mid$(Text1.Text, intLeft + 1, intRight - intLeft - 1)

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Get char between "[" and "]"

    Is there only one sequence of [ ] in the textbox, or might there be more than one?

  5. #5

    Thread Starter
    Addicted Member g-mie's Avatar
    Join Date
    Jan 2004
    Location
    EarTh
    Posts
    212

    Re: Get char between "[" and "]"

    There is only one set of [ and ]
    Let say xxxxxx[yyyyyyyyy]zzzzzzzz
    x,y and z is not fix count.

  6. #6

    Thread Starter
    Addicted Member g-mie's Avatar
    Join Date
    Jan 2004
    Location
    EarTh
    Posts
    212

    Re: Get char between "[" and "]"

    oopsss....both code can running well.
    Thanks guys.

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