picture boxes

juggernot

Well-known member
Joined
Sep 28, 2006
Messages
173
Programming Experience
Beginner
This is probably very simple, but how do you change the picture in a picture box in the code? Whenever I try it says the words in my file path are not declared.
 
lol, i guess it wasn't useless. I'm still having problems, it's not finding the picture i want. I had typed in the correct path, and it didn't work. I also tried using just the file name and putting the image in the root folder of the project, but that didn't work either. Here is an example of my code:

If card = 1 Then
Me.PictureBox1.Image.FromFile("acespades.jpg")
End If
 
Hmm, I really hope someone replies soon or I'l figure out it all myself... anyhow, I've got the image to change, but now I want it to be one of 4 images if my variable is a certain value. This is for my blackjack program if you are wondering. The following isn't code, but rather the logic behind the code:
if card = 1 than show ace
if suit = 1 than show ace of spades
if suit = 2 than show ace of diamonds
if suit = 3 than show ace of hearts
if suit =4 than show ace of clubs

I have suit and card as random integers, between appropriate numbers of course.I made card = 1 because I only have aces ready. For some reason however I can only show the ace of spades unless I specify that suit = 2,3,4

my actual code:
myRandomNumber = RandomClass.Next(1, 10)
card = myRandomNumber
card = 1
myRandomNumber = RandomClass.Next(1, 2)
suit = myRandomNumber


If suit = 1 And card = 1 Then
Me.PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Roxie Robertson\My Documents\Visual Studio Projects\BlackJack\acespades.jpg")
ElseIf suit = 2 And card = 1 Then
Me.PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Roxie Robertson\My Documents\Visual Studio Projects\BlackJack\acediamonds.jpg")
 
Back
Top