Results 1 to 6 of 6

Thread: [2005] Another small quick question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Resolved [2005] Another small quick question

    Just a quick thing, Code below is checking collision with tags:
    vb Code:
    1. If TypeOf Wall Is PictureBox AndAlso Wall.Tag = "Item Fireball" Then
    2.                 If Wall.Bounds.IntersectsWith(Pic1.Bounds) Then
    3.                     Me.Controls.Remove(Wall)
    4.                 End If
    5.             End If

    how do i do it so it detects the tag of "Item Fireball" as something like "Item *" as i will have multiple items, each having a tag starting with the word "Item".
    Last edited by squrrilslayer; Apr 4th, 2008 at 06:29 AM.

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

    Re: [2005] Another small quick question

    Please provide descriptive titles for your threads in future.
    vb.net Code:
    1. If CStr(Wall.Tag).StartsWith("Item ") Then
    VB also has a LIKE operator that you can use to make wildcard comparisons:
    vb.net Code:
    1. If CStr(Wall.Tag) Like "Item *" Then
    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
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Re: [2005] Another small quick question

    ok. and what if the string i want to detect is somewhere in the middle?

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

    Re: [2005] Another small quick question

    I edited my previous post to use the Like operator, which can be used to answer you most recent question. Note that the String class also has a Contains method that would do the job.
    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Re: [2005] Another small quick question

    ok thanks alot!

  6. #6
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Another small quick question

    Read my signature (the resolve part)

    And I can't believe I've never seen that before!!! Thats "Like" crazy

    Cheers

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