Results 1 to 14 of 14
  1. #1
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed

    Need Help with Buttons and Images

    Hey guys, i'm making a program that in the end will be like a memory program for cards.

    here is a few images:

    So this image is just the basic program layout, it's really simple (and unfinished with the images)


    This next image is when the card is selected it turns green


    So, my question is, how would i make it so that If the card is selected (it's highlighted green) And, the button "mine" is pressed the shade will change to a blue color (which is just another image), Alternatively if the card is selected and the "thiers" button is pressed, it will change red, and that again is just a diffrent image similar to the selected image. And finally if the card is selected and remove is pressed the card will be removed (i think i got that part down using the hide() method and then using the show() method when i want to reset it).

    My code currently when the card is selected:
    Code:
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click, Button2.Click
            'Ace of Clubs
            PictureBox1.Image = My.Resources.Ace_of_Clubs___Selected
    
        End Sub
    I have tryed alot of diffrent things For the image color changing, but none of them Have seemed to work.

    The closest i have gotten is this:
    Code:
    Dim Btn2Clicked As Boolean = False
    Dim Btn3Clicked as Boolean = False
    Dim Btn4Clicked as Boolean = false
       
    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
      
    If Btn2Clicked = True Then
    PictureBox1.image = My.Resources.Ace_of_Clubs___Mine
    Btn2Clicked = True
    ElseIf
    Btn3Clicked = True Then
    PictureBox1.Image = My.Resources.Ace_of_Clubs___Thiers
    Btn3Clicked = True      
    ElseIf
    Btn4Clicked = true then
    PictureBox1.Hide()
    Btn4Clicked = True
    
    
    End If  
    End Sub
    Now, this is only for one picturebox, and there are 36 picture boxes total. I'm trying to get it for all of them selected and a button is pressed to change to that color or shade.

    I also tryed using an Image array that looked like this:
    (I only did 4 pictures in this one, even though the normal one is 9)

    Code:
    Dim PicBoxes(3) As Image
    
    PicBoxes(0) = Image.FromFile(My.Resources.Ace_of_Clubs___Mine)
    PicBoxes(1) = Image.FromFile(My.Resources.King_of_Clubs___Mine)
    PicBoxes(2) = Image.FromFile(My.Resources.Queen_of_Clubs___Mine)
    PicBoxes(3) = Image.FromFile(My.Resources.Ten_of_Clubs___Mine)
    However, after doing this array, i wasn't quite sure where to go with it.

    Any help with this would be highly appreciated. If there is not enough information here, let me know and i'll add more information to better show the problem.
    Last edited by money001; 04-15-2013 at 10:13 PM.

  2. #2
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    Bump, Still looking for help please!

  3. #3
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    Bump Again please, Need a bit of insight as to how to accomplish this task

  4. #4
    rileyjstrickland's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Florida
    Posts
    649
    Reputation
    90
    Thanks
    4,008
    My Mood
    Relaxed
    So you want to change image on button click?
    I'd recommend making a custom picturebox control with the following extra variables.
    Code:
    is_selected
    Then on the button click do the following
    Code:
    for each item in me.controls
    if typeof item is card then
    if item.is_selected then
    'do your mine/their's image code
    end if
    end if
    next
    The code may contain an error as I have not tested it, but wrote it out-of-head.

    If You Like My Releases, Hit The Thanks button!
    Follow the rules.

    Successful Purchases: 2
    @The403
    @sundy42
    Successful Sales: 1
    @wZ. Gali
    Scammed: 1

    Favorite Quotes:
    Quote Originally Posted by Doc View Post
    Who cares about simplified mandarin. The only problem here is that Cantonese (and Hokkien) is no longer being taught, but guess what, times change. There have been thousands of languages that have been lost to the ages, you'd be pissing in the wind to try and stop that.

  5. #5
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    This may sound like a dumb question, but where would i input the is_selected variable?

    Like, should i just make a new Private Sub called "is_selected" or would that be a new class or what? (I don't want to over complicate things)

    Edit: i try'd to make a public function and here is the code that i have written for it:

    Code:
    Dim Selected As Boolean = False
    
        Public Function isSelected()
            Selected = True
            If isSelected() = Selected Then
                PictureBox1.Image = My.Resources.Ace_of_Clubs___Selected
            End If
    
            Return 0
        End Function
    and here is the code in the card:

    Code:
    Private Sub PictureBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
            'Ace of Clubs
            isSelected()
        End Sub
    (I know i screwed this up in the isSelected Function however i'm not sure how to fix it to make it work for every card (as atm it only would work if it actually worked for the picturebox1))
    Last edited by money001; 04-16-2013 at 11:46 PM.

  6. #6
    rabbit.coder's Avatar
    Join Date
    Mar 2013
    Gender
    male
    Posts
    29
    Reputation
    10
    Thanks
    50
    Make a new project and give this a go.

    2 pictureboxes, 1 button and 2 resources(images)

    not the best way but you will think about it differently with this approach. if you need help understanding it send me a message.
    but basically when you click on a picturebox it sets "SelectedCard" string to the controls name.

    Code:
    Public Class Form1
        Dim SelectedCard As String
    
        Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
            Dim picBox As PictureBox = DirectCast(sender, PictureBox)
            Dim name As String = picBox.Name
            SelectedCard = name
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim pic As PictureBox
            pic = Me.Controls(SelectedCard)
            pic.Image = My.Resources.happy
        End Sub
    
        Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
            Dim picBox As PictureBox = DirectCast(sender, PictureBox)
            Dim name As String = picBox.Name
            SelectedCard = name
        End Sub
    
    End Class
    If it helps dont forget to Thanks. if you need more help send me a message.

  7. #7
    rileyjstrickland's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Florida
    Posts
    649
    Reputation
    90
    Thanks
    4,008
    My Mood
    Relaxed
    Quote Originally Posted by money001 View Post
    This may sound like a dumb question, but where would i input the is_selected variable?

    Like, should i just make a new Private Sub called "is_selected" or would that be a new class or what? (I don't want to over complicate things)

    Edit: i try'd to make a public function and here is the code that i have written for it:

    Code:
    Dim Selected As Boolean = False
    
        Public Function isSelected()
            Selected = True
            If isSelected() = Selected Then
                PictureBox1.Image = My.Resources.Ace_of_Clubs___Selected
            End If
    
            Return 0
        End Function
    and here is the code in the card:

    Code:
    Private Sub PictureBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
            'Ace of Clubs
            isSelected()
        End Sub
    (I know i screwed this up in the isSelected Function however i'm not sure how to fix it to make it work for every card (as atm it only would work if it actually worked for the picturebox1))
    Just make a public boolean
    Code:
    public is_selected as boolean
    Then when the button is clicked
    Code:
    is_selected = true

    If You Like My Releases, Hit The Thanks button!
    Follow the rules.

    Successful Purchases: 2
    @The403
    @sundy42
    Successful Sales: 1
    @wZ. Gali
    Scammed: 1

    Favorite Quotes:
    Quote Originally Posted by Doc View Post
    Who cares about simplified mandarin. The only problem here is that Cantonese (and Hokkien) is no longer being taught, but guess what, times change. There have been thousands of languages that have been lost to the ages, you'd be pissing in the wind to try and stop that.

  8. #8
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    Quote Originally Posted by rileyjstrickland View Post
    Just make a public boolean
    Code:
    public is_selected as boolean
    Then when the button is clicked
    Code:
    is_selected = true
    So, After how about for multiple pictureboxes how would i do that? I understand how to do it now for a single picturebox, and whenever i click on "mine" or "thiers" or "remove" it is supposed to set

    Code:
    is_selected = false
    But i'm trying to think of how to set it for picture boxes 1, 2, 3 and so on as to have multiple pictureboxes instead of just one

    Edit: I think i just had a brain fart there, All i do is make each picture box is_selected = true, however, i still don't understand how to make it detect "if picturebox1.clicked & is_selected() then change to so and so card", or "if is_selected() & Button3.clicked then change to some card"

    Sorry if i'm saying it a bit unclear, i'll try to fix it up to make it more understandable.

    ---------- Post added at 09:04 PM ---------- Previous post was at 08:59 PM ----------

    Quote Originally Posted by rabbi*****der View Post
    Make a new project and give this a go.

    2 pictureboxes, 1 button and 2 resources(images)

    not the best way but you will think about it differently with this approach. if you need help understanding it send me a message.
    but basically when you click on a picturebox it sets "SelectedCard" string to the controls name.

    Code:
    Public Class Form1
        Dim SelectedCard As String
    
        Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
            Dim picBox As PictureBox = DirectCast(sender, PictureBox)
            Dim name As String = picBox.Name
            SelectedCard = name
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim pic As PictureBox
            pic = Me.Controls(SelectedCard)
            pic.Image = My.Resources.happy
        End Sub
    
        Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
            Dim picBox As PictureBox = DirectCast(sender, PictureBox)
            Dim name As String = picBox.Name
            SelectedCard = name
        End Sub
    
    End Class
    If it helps don't forget to Thanks. if you need more help send me a message.
    I'm a bit unsure of what the "My.Resources.happy" is for. Can you please elaborate on this some? I read the code over a few times and it still doesn't make any sense to me.

    edit: Alright, so i figured out what the .happy is for, and i changed it to the selected image card however, it just cycles through the cards and "selecting" them each one by one changing them to the same selected image, instead of diffrent images, but it was a good try.
    Last edited by money001; 04-17-2013 at 09:08 PM.

  9. #9
    rabbit.coder's Avatar
    Join Date
    Mar 2013
    Gender
    male
    Posts
    29
    Reputation
    10
    Thanks
    50
    sorry about the .happy :/

    What this does is when the picture box is clicked the string "SelectedCard" will be set to that picture boxes name eg. PictureBox1.
    this is so you dont accually have to know the name of the picturebox.
    Code:
        
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
            Dim picBox As PictureBox = DirectCast(sender, PictureBox)
            Dim name As String = picBox.Name
            SelectedCard = name
        End Sub

  10. #10
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    So, i'm still a bit unsure what to do with this section of code though:

    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim pic As PictureBox
            pic = Me.Controls(SelectedCard)
            pic.Image = My.Resources.happy
        End Sub
    The .happy isn't apart of my resources and as such, i can't debug because it gives me an error Should i rename it to something else?

    ---------- Post added at 10:07 PM ---------- Previous post was at 10:01 PM ----------

    So, i fixed it up a bit however i run into a problem when working with that .happy script and that is, that i should be able to select multiple cards at a time, and i need them to change to diffrent cards not just 1 single card (unless i can somehow add an opaque layer over the current image.

  11. #11
    rileyjstrickland's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Florida
    Posts
    649
    Reputation
    90
    Thanks
    4,008
    My Mood
    Relaxed
    Again, make a custom picturebox control with the boolean "is_selected"
    Then, when you click on it set the boolean to true
    then on the button click to the following
    Code:
    for each item in me.controls
    if typeof item is custompicturebox then
    item.MINE/THEIRS = true
    end if
    next


    ---------- Post added at 02:36 PM ---------- Previous post was at 02:35 PM ----------

    Quote Originally Posted by rabbi*****der View Post
    sorry about the .happy :/

    What this does is when the picture box is clicked the string "SelectedCard" will be set to that picture boxes name eg. PictureBox1.
    this is so you dont accually have to know the name of the picturebox.
    Code:
        
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
            Dim picBox As PictureBox = DirectCast(sender, PictureBox)
            Dim name As String = picBox.Name
            SelectedCard = name
        End Sub
    No need to do that since the only object calling that sub is Picturebox1

    If You Like My Releases, Hit The Thanks button!
    Follow the rules.

    Successful Purchases: 2
    @The403
    @sundy42
    Successful Sales: 1
    @wZ. Gali
    Scammed: 1

    Favorite Quotes:
    Quote Originally Posted by Doc View Post
    Who cares about simplified mandarin. The only problem here is that Cantonese (and Hokkien) is no longer being taught, but guess what, times change. There have been thousands of languages that have been lost to the ages, you'd be pissing in the wind to try and stop that.

  12. #12
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    Quote Originally Posted by rileyjstrickland View Post
    Again, make a custom picturebox control with the boolean "is_selected"
    Then, when you click on it set the boolean to true
    then on the button click to the following
    Code:
    for each item in me.controls
    if typeof item is custompicturebox then
    item.MINE/THEIRS = true
    end if
    next
    [COLOR="Silver"]
    This may sound like a stupid question, but is that the actual code i should be entering or should i write the code based on what it says, Because that's what i think you mean but i'm not exactly sure.

  13. #13
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    Bump please

  14. #14
    money001's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    210
    Reputation
    5
    Thanks
    19
    My Mood
    Stressed
    Bump bump...

Similar Threads

  1. [Help Request] Help with XIGNCODE and xSherlock
    By rushflitz in forum Alliance of Valiant Arms (AVA) Help
    Replies: 1
    Last Post: 03-07-2013, 12:19 PM
  2. [Help Request] I'm a noob. I need help with menus and basics.
    By paddytrick in forum DayZ Help & Requests
    Replies: 2
    Last Post: 03-05-2013, 11:55 AM
  3. [Help Request] help with hack and injector
    By -_RedBull in forum CrossFire Help
    Replies: 2
    Last Post: 03-03-2013, 01:31 PM
  4. [Help Request] Help with running and working Good stuff Lite v1.006.
    By hellanchaos in forum Vindictus Help
    Replies: 1
    Last Post: 10-09-2011, 05:44 PM
  5. Help with Crosshairs and VB6!
    By condor01 in forum WarRock - International Hacks
    Replies: 4
    Last Post: 07-03-2007, 08:39 PM