PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Trying to use the pic my image code and it won't let me use it.-VBForums
Results 1 to 12 of 12

Thread: Trying to use the pic my image code and it won't let me use it.

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    11

    Trying to use the pic my image code and it won't let me use it.

    Hey guys,

    I am trying to make a poker Calculator. At the moment I am trying to have a click of a button change the picture in a picture box and I am getting this error saying picmyimage is not declared or it could be that it may be inaccessible due to its protection level.. Below is the code. Am I doing this right, could this be used, or is there a better way of achieving this? I am new to this if i have to declare it how would I achieve this?

    HTML Code:
    Public Class Form2
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            picMyImage.Image = My.Resources.aceofhearts
        End Sub
    
       
    
    End Class

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,580

    Re: Trying to use the pic my image code and it won't let me use it.

    Be sure that your form has a picture box control and its name is picMyImage



  3. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,483

    Re: Trying to use the pic my image code and it won't let me use it.

    Considerations

    This will work as picMyImage is in scope
    Code:
    Public Class Form2
        Private picMyImage As New PictureBox
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            picMyImage.Image = My.Resources.aceofhearts
        End Sub
    End Class
    This will not as picMyImage is not in scope as picMyImage is only in scope for the procedure it was declared in.
    Code:
    Public Class Form2
        Private Sub CreateSomething()
            Dim picMyImage As New PictureBox
        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            picMyImage.Image = My.Resources.aceofhearts
        End Sub
    End Class
    If myPicImage was declared in another module or form it must be declared as public at form or module level.

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    11

    Re: Trying to use the pic my image code and it won't let me use it.

    I just took the picmyimage out and put in picturebox1. image and it worked fine. There's going to 7 boxes were I can put images into, so I might just use the name of the box. Also Is there a way were I could set a code if there is a picture added to picbox1 use picbox2 to insert the image?

  5. #5
    Fanatic Member proneal's Avatar
    Join Date
    May 2011
    Posts
    762

    Re: Trying to use the pic my image code and it won't let me use it.

    picbox1.Image = picbox2.Image would work

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    11

    Re: Trying to use the pic my image code and it won't let me use it.

    I wanted to try to do this (Code Below), but it is giving me an error saying expression expected, but I ran the program and it did fine. I don't know if this will be the right way to do it or not but for all 52 cards (button clicks) this code will be there. What I am trying to achieve is this. There will be the hole deck of cards on a separate window sorted by order and in suit. The person will pick two cards for there hand that they got. First card going in the picbox1 and the second one in picbox2. If they have a hand that is worth it and decide to stay in the flop will come next with 3 more cards. Then they will put down what cards are showing on the board with the two cards in there hand not being touched. This will go on for 2 more cards to be dealt. While this is going on I want to try to have the percentage that they might win the game with there 2 cards in there hand and any other cards that come if they stay in. I am quite new at this so I am having all sorts of fun right now. If anyone knows of any books or online tutorials on this stuff that will be great. Otherwise any other help is appreciated.

    HTML Code:
    Public Class Form2
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Select Case True
                Case  Form1.PictureBox1.Image == false
                    Form1.PictureBox1.Image = My.Resources.aceofhearts
    
                    'Case  Form1.PictureBox1.Image == false
                    '    Form1.PictureBox1.Image = My.Resources.aceofhearts
    
                    '  Case  Form1.PictureBox1.Image == false
                    '    Form1.PictureBox1.Image = My.Resources.aceofhearts
    
                    'Case  Form1.PictureBox1.Image == false
                    '    Form1.PictureBox1.Image = My.Resources.aceofhearts
    
                    'Case  Form1.PictureBox1.Image == false
                    '    Form1.PictureBox1.Image = My.Resources.aceofhearts
    
                    'Case  Form1.PictureBox1.Image == false
                    '    Form1.PictureBox1.Image = My.Resources.aceofhearts
    
                    'Case  Form1.PictureBox1.Image == false
                    '    Form1.PictureBox1.Image = My.Resources.aceofhearts
    
            End Select
    
        End Sub
    End Class

  7. #7
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,483

    Re: Trying to use the pic my image code and it won't let me use it.

    The Image Property is not a Boolean. And == is improper.

  8. #8
    Fanatic Member proneal's Avatar
    Join Date
    May 2011
    Posts
    762

    Re: Trying to use the pic my image code and it won't let me use it.

    vb Code:
    1. Select Case True
    2.             Case  Form1.PictureBox1.Image == false

    Using Select Case incorrectly there.

    What are you testing to see if True or not? to see if image inside the picturebox control?
    You can test whether Image or not using is nothing.

    Good Luck!

  9. #9
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,483

    Re: Trying to use the pic my image code and it won't let me use it.

    I have not tried the following but it might be worth checking it out

    MSDN Card Game Starter Kit

  10. #10

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    11

    Re: Trying to use the pic my image code and it won't let me use it.

    Proneal yes that is what I am trying to do. How would I achieve in testing to see if there is an image inside the picbox?

  11. #11
    Fanatic Member proneal's Avatar
    Join Date
    May 2011
    Posts
    762

    Re: Trying to use the pic my image code and it won't let me use it.

    vb Code:
    1. If picbox.image is nothing then
    2. 'code to add image here or whatever you want to do
    3. end if

    There ia a cxard game starter kit on that link Kevininstructor gave.
    I installed it and having a look.
    You might want to do that also and see how the developer created the blackjack game.

    TY Kevin and

    Good Luck!

  12. #12

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    11

    Re: Trying to use the pic my image code and it won't let me use it.

    I am looking at it to now. Also Thanks you Kevin for this. Other then this is there any books that will help me out along the way?

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width