dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: IF statement looking for a string within the object

  1. #1
    Join Date
    Nov 2003
    Location
    Australia
    Posts
    137

    IF statement looking for a string within the object

    I want to use the if statement to find whether a field contains certain data.

    In SQL I would use the where aaaaa like %thedata% to extract rows satisfying the where test.

    Does VB have a function or IF statement condition test that allows looking for substring data?
    TT

  2. #2
    Join Date
    Feb 2002
    Location
    Australia
    Posts
    125
    Try Instr function

  3. #3
    Join Date
    Nov 2003
    Location
    Australia
    Posts
    137
    Thanks Ahmed.

    What if I want to read a string from right to left searching for a character.

    for example

    If I have a date text field on my form and I want to determine if the user entered the year with the century.

    ie. 1/2/04 or 1/2/2004

    I was hoping to read the characters from right to left looking for the / and counting the characters.
    I should only ever get the results 2 and 4 if proper dates entered.
    TT

  4. #4
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    InstrRev
    Be nice to Harley riders...

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    string matching and string replacing

    It may take some efforts if you never used, but Regular
    expressions are great for find and replace job in string.
    If the job is not a simple one (else it is not worth the effort),
    have a look at RegExp in Mdsn, to get an idea...
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)