Results 1 to 8 of 8

Thread: Wildcard??

  1. #1

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Question Wildcard??

    Hello

    How would I, in an If - Then statement, use a wildcard in certain locations. For example:
    VB Code:
    1. If String = "String_" & [b]Wildcard[/b] Then

    Thanks,
    Rudi



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Wildcard??

    You can't really use patterns like that in direct string comparisons. The String class has some members that can help in simple cases, like StartsWith, EndsWith, IndexOf, IndexOfAny, LastIndexOf and LastIndexOfAny. Anything more complex than what those can do is going to require the use of regular expressions through the Regex class, which is an all-powerful pattern matching mechanism. Some regular expressions can get pretty complex but you can match basically any pattern you can think of.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Re: Wildcard??

    That's fine, thanks alot



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

  4. #4
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Wildcard??

    You could use the LIKE operator;
    VB Code:
    1. IF "string1" LIKE "string*" THEN
    2. ...
    3. END IF
    TPM

    Add yourself to the VBForums Frappr Map!!

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Wildcard??

    Well I'll be b*ggered! I take back everything I said (do you think anyone noticed ). The stupid thing is I've even used Like myself, but not for quite some time and I'd forgotten it even existed. Time for a memory upgrade I'd say. Might get a new case while I'm at it. This old one's looking a bit shabby.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Wildcard??


    If you need help with your upgrade come to GPC
    TPM

    Add yourself to the VBForums Frappr Map!!

  7. #7

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Re: Wildcard??

    Thanks alot -TPM-, but the one that jmcilhinney sent to me works perfectly fine, and does exactly what I want to do

    Thanks again



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

  8. #8
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Wildcard??

    No problem! (BTW: forgot to say the * can go anywhere, not just the end)
    TPM

    Add yourself to the VBForums Frappr Map!!

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