Results 1 to 7 of 7

Thread: Looking for some coding help.

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Posts
    3

    Question Looking for some coding help.

    Hey people, I'm a newbie in programming; taking my first class in VB.NET at my school.

    I'm trying to work on my last assignment and I'm completely stuck. So any help would be appreciated. Sorry for the long post.

    I'll try to explain the assignment to you the best I can.

    It's a simple game. There are 16 (equal size) picboxes arranged 4x4. There's also another picbox to the side. Each picbox in the 4x4 will be randomly assigned an image from the bin folder.

    The 17th picbox (lets call it picWin) to the side will also be assigned randomly an image.

    The goal of the game is to find (by clicking on) the image in 4x4 of boxes until you find the image that matches the image in picWin.

    I have no problem figuring out how to code random assignment to each box. The problem I do have is figuring out how to pick the winning image which will match the image in picWin.

    I hope that makes sense.

    Thanks.

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    How, exactly, are you displaying your pics? Looking into properties and methods of the control you use might help.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Posts
    3
    they are being displayed with the image property.

    Here's some line of code from my program:

    VB Code:
    1. Private Sub Load_Image(ByRef PBImage)
    2.         'Procedure that will assign a random picture from the array to the picture box
    3.  
    4.         myNum = randomNum.Next(0, 15)
    5.         PBImage.Image = Image.FromFile(Application.StartupPath & "\" & PicturesArray(myNum))
    6.  
    7.     End Sub


    This code is being called by: Load_Image(pic1) in a click event.

    pic1 is one of the picture boxes in the 4x4 arrangement. There's an array that has been dimensioned with the file names of the images.
    Last edited by afrdzak; Dec 7th, 2003 at 09:51 PM.

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    My suggestion would be to put the file name in the PB's .Tag property. Then you can compare the Tags to see if they match.

    PBImage.Tag = PicturesArray(myNum)

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Posts
    3
    Originally posted by hellswraith
    My suggestion would be to put the file name in the PB's .Tag property. Then you can compare the Tags to see if they match.

    PBImage.Tag = PicturesArray(myNum)
    Yeah, that's one of the methods my dad mentioned, however, a problem with using this method is this. There's no guarantee that all the pictures will be assigned to a PictureBox. So, it's possible that some instances of the game, there's no chance of winning because there was never a randomly selected image assigned into the group of Picture Boxes.
    Last edited by afrdzak; Dec 8th, 2003 at 01:31 AM.

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Wink

    Wow, how cool is it to have a Dad that can code.

    Respect.
    I don't live here any more.

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by afrdzak
    Yeah, that's one of the methods my dad mentioned, however, a problem with using this method is this. There's no guarantee that all the pictures will be assigned to a PictureBox. So, it's possible that some instances of the game, there's no chance of winning because there was never a randomly selected image assigned into the group of Picture Boxes.
    OK, so run a routine that goes through the 16 PB's to see if any of the tags match up with the other PB tag. If one of them does, you know you have a match in there, if not, well, you don't have a match. This looks to be about 10 - 20 lines of code to do all you are talking about. I think you are making this too hard.

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