CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Location
    Sarawak,Malaysia
    Posts
    5

    seacrching for a specified text from a string.

    Hi all,
    i have this problem... i don't have any idea on how to search or find or findout what is in a string. For instance i have a string '123' and i want to know whether the string '123' contains a '2'.... it must sound simple but i've tried everything i know and still can't get it. pls...help...me..


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: seacrching for a specified text from a string.

    try this



    dim s as string
    dim l as long

    s = "123"
    l = instr(1,s,"2") 'should return 2 to l, the position where the char "2" occur

    s = "123"
    l = instr(1,s,"4") 'should return 0 to l, as no char "4" found in string s.




    HTH

    cksiow
    http://vblib.virtualave.net - share our codes


  3. #3
    Join Date
    Feb 2001
    Posts
    54

    Re: seacrching for a specified text from a string.

    Hello:

    You can also do this: You can textbox and Richtextbox to find String.

    RichTextBox2.UpTo (Text1.Text)
    RichTextBox2.SetFocus

    However, the cursor must before the String to be searched.
    You can find more information about it on the Visual Basic 6:Black Book by Steven Holzner.

    Good Luck


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

Featured