Shaun B

Where have my pictures gone

i am new to programming and have made a somewhat niaive high/low game played with a pack of cards (.bmp format). the card pictures are held in "my pictures" and referenced in the program from this location when i call them in the program, however when i publish the program and install it on another computer (which has VB2005 installed) the pictures won't display, can anybody help



Re: Visual Basic Express Edition Where have my pictures gone?

clint 2

shaun

your pictures are not the same as my pictures

if your pictures are stored in my pictures, that does not mean they are on the other pc

you would have to make sure they are also stored on the other pc's my pictures

I think you should have to add the pictures to your resources

and reference them from there

clint






Re: Visual Basic Express Edition Where have my pictures gone?

Shaun B

Clint 2

thanks for the advice

i will give it a go

kindest regards

shaun





Re: Visual Basic Express Edition Where have my pictures gone?

Shaun B

arghhhhhhh

still no luck

i have loaded the bitmaps into the resources area but when i publish the program and run it on

another computer the bitmaps are not there, can anyone help before i flight test my computer





Re: Visual Basic Express Edition Where have my pictures gone?

js06

If you are expecting the pics to be in the installed computers my pictures folder after you placed them in your resources and then published, that doesn't happen automatically.

you need to tell the app where to look for them in your resources or you need to copy them to the my pictures folder on the installed computer.

post some code so we can see where you are having trouble with it.






Re: Visual Basic Express Edition Where have my pictures gone?

ReneeC

Shaun has made a good start. But he needs to relate to the resources as resources.

Picturbox1.image = my.resources.AceOfHearts

Etc






Re: Visual Basic Express Edition Where have my pictures gone?

clint 2

go to vb2005....projects...your application....bin.....debug......resources

and make sure your pics are there.....if not....copy and paste them to this folder

then publish your app and it should work......

personally, I find my resources a bit of a nightmare......so much so that I just copy my pics to a folder on the other pc

e.g

create a folder called card pics....place your images in this folder

copy folder to the pc...........ie......C:\card pics

in your application....do

If My.Computer.FileSystem.FileExists("C:\card pics\2 of clubs.jpg") Then

picturebox1.image=. Image.FromFile("C:\card pics\2 of clubs.jpg")

Else
msgbox "please copy card pics folder to your C:\directory "

End If

...........................................................

now install your app on other pc and away you go

this may not be the best way but it definitly works

clint






Re: Visual Basic Express Edition Where have my pictures gone?

bdbodger

In a card game I did I loaded the pictures for the cards into a ImageList control. I don't know if they then become embedded or not I have never published the app .



Re: Visual Basic Express Edition Where have my pictures gone?

ReneeC

They be there hen you publish but Image list images are limited in size to 256 x 256.




Re: Visual Basic Express Edition Where have my pictures gone?

Shaun B

To everyone

thanks for all the hints and assistance,

there is plenty for me to get on and try

and lots of new directions for me to move

in. As requested, i will add a listing of

my code (hope i load it ok!), apologies

if it appears a bit niaive but i haven't even

got to the "case select" chapter yet (that's

my excuse anyway). i am a big boy and open

to all assistance/criticism etc so feel free

to comment. My playing cards are named

"a1.bmp" to "a52.bmp" and "blueback.bmp"

and there is a copy of them in the Resources

folder in the "solution explorer".

Once again thanks

shaun

Public Class Form1

Dim FlashCounter As Integer = 0 'counter used for flashing the winner sign

Dim CardValue(10) As Integer 'array used to hold value of card

Dim CardNumber As Integer 'current card

Dim SelectedCards(10) As Integer 'array containing the 7 cards

Dim WinCounter As Integer = 1

Sub TheSevenCards()

Randomize() 'sets random funtion

Do

Dim LoopCounter As Integer 'standard loop integer

Dim intAssess As Integer = 1 'creates value that is used to exit loop if numbers are different.

'get 10 random numbers

For LoopCounter = 0 To 9

SelectedCards(LoopCounter) = Int(Rnd() * 52) + 1

Next LoopCounter

'are any of the cards the same

'there must be an easier way! nested loops

If SelectedCards(0) = SelectedCards(1) Then intAssess = 0

If SelectedCards(0) = SelectedCards(2) Then intAssess = 0

If SelectedCards(0) = SelectedCards(3) Then intAssess = 0

If SelectedCards(0) = SelectedCards(4) Then intAssess = 0

If SelectedCards(0) = SelectedCards(5) Then intAssess = 0

If SelectedCards(0) = SelectedCards(6) Then intAssess = 0

If SelectedCards(0) = SelectedCards(7) Then intAssess = 0

If SelectedCards(0) = SelectedCards(8) Then intAssess = 0

If SelectedCards(0) = SelectedCards(9) Then intAssess = 0

If SelectedCards(1) = SelectedCards(2) Then intAssess = 0

If SelectedCards(1) = SelectedCards(3) Then intAssess = 0

If SelectedCards(1) = SelectedCards(4) Then intAssess = 0

If SelectedCards(1) = SelectedCards(5) Then intAssess = 0

If SelectedCards(1) = SelectedCards(6) Then intAssess = 0

If SelectedCards(1) = SelectedCards(7) Then intAssess = 0

If SelectedCards(1) = SelectedCards(8) Then intAssess = 0

If SelectedCards(1) = SelectedCards(9) Then intAssess = 0

If SelectedCards(2) = SelectedCards(3) Then intAssess = 0

If SelectedCards(2) = SelectedCards(4) Then intAssess = 0

If SelectedCards(2) = SelectedCards(5) Then intAssess = 0

If SelectedCards(2) = SelectedCards(6) Then intAssess = 0

If SelectedCards(2) = SelectedCards(7) Then intAssess = 0

If SelectedCards(2) = SelectedCards(8) Then intAssess = 0

If SelectedCards(2) = SelectedCards(9) Then intAssess = 0

If SelectedCards(3) = SelectedCards(4) Then intAssess = 0

If SelectedCards(3) = SelectedCards(5) Then intAssess = 0

If SelectedCards(3) = SelectedCards(6) Then intAssess = 0

If SelectedCards(3) = SelectedCards(7) Then intAssess = 0

If SelectedCards(3) = SelectedCards(8) Then intAssess = 0

If SelectedCards(3) = SelectedCards(9) Then intAssess = 0

If SelectedCards(4) = SelectedCards(5) Then intAssess = 0

If SelectedCards(4) = SelectedCards(6) Then intAssess = 0

If SelectedCards(4) = SelectedCards(7) Then intAssess = 0

If SelectedCards(4) = SelectedCards(8) Then intAssess = 0

If SelectedCards(4) = SelectedCards(9) Then intAssess = 0

If SelectedCards(5) = SelectedCards(6) Then intAssess = 0

If SelectedCards(5) = SelectedCards(7) Then intAssess = 0

If SelectedCards(5) = SelectedCards(8) Then intAssess = 0

If SelectedCards(5) = SelectedCards(9) Then intAssess = 0

If SelectedCards(6) = SelectedCards(7) Then intAssess = 0

If SelectedCards(6) = SelectedCards(8) Then intAssess = 0

If SelectedCards(6) = SelectedCards(9) Then intAssess = 0

If SelectedCards(7) = SelectedCards(8) Then intAssess = 0

If SelectedCards(7) = SelectedCards(9) Then intAssess = 0

If SelectedCards(8) = SelectedCards(9) Then intAssess = 0

If intAssess = 1 Then Exit Do 'exit if all cards are different

Loop

'calculate values of cards, 1 point for an ace up to 13 points for a king

Dim loopcounter1 As Integer 'local variable used for the loop

For loopcounter1 = 0 To 9

If SelectedCards(loopcounter1) > 0 And SelectedCards(loopcounter1) < 14 Then CardValue(loopcounter1) = SelectedCards(loopcounter1)

If SelectedCards(loopcounter1) > 13 And SelectedCards(loopcounter1) < 27 Then CardValue(loopcounter1) = SelectedCards(loopcounter1) - 13

If SelectedCards(loopcounter1) > 26 And SelectedCards(loopcounter1) < 40 Then CardValue(loopcounter1) = SelectedCards(loopcounter1) - 26

If SelectedCards(loopcounter1) > 39 And SelectedCards(loopcounter1) < 53 Then CardValue(loopcounter1) = SelectedCards(loopcounter1) - 39

Next

'reset pictures of all the cards apart from first card which displays its value. Blueback is the rear of the card picture

pbxCard1.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(0)) & ".bmp"

pbxCard2.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard3.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard4.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard5.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard6.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard7.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard8.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard9.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

pbxCard10.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\BlueBack.bmp"

'print out numbers for development purposes, textbox1 has been removed

'Dim strnumbers As String = ""

'For loopcounter1 = 0 To 9

' strnumbers = strnumbers & Str(SelectedCards(loopcounter1)) & " "

'Next loopcounter1

'For loopcounter1 = 0 To 9

' strnumbers = strnumbers & Str(CardValue(loopcounter1)) & ""

'Next loopcounter1

'lblOutput1.Text = strnumbers

'set card number to represent first card

CardNumber = 1

End Sub

Sub EndGame()

btnHigher.Enabled = False

btnLower.Enabled = False

End Sub

Sub winner()

Timer1.Enabled = True

EndGame()

End Sub

Private Sub btnHigher_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnHigher.Click

'display the next card, cardnumber variable tells us which card is current

If CardNumber = 1 Then pbxCard2.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 2 Then pbxCard3.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 3 Then pbxCard4.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 4 Then pbxCard5.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 5 Then pbxCard6.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 6 Then pbxCard7.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 7 Then pbxCard8.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 8 Then pbxCard9.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 9 Then pbxCard10.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

' If CardNumber = 10 Then pbxCard7.ImageLocation = ("C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\" & CStr(SelectedCards(CardNumber)) & ".bmp")

'did player get the selection right

If CardValue(CardNumber) > CardValue(CardNumber - 1) Then CardNumber = (CardNumber + 1) Else EndGame()

'did player get All the cards right

If CardNumber = 10 Then winner()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewGame.Click

'code for a new game

TheSevenCards()

btnHigher.Enabled = True

btnLower.Enabled = True

End Sub

Private Sub btnLower_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLower.Click

'see notes for btnHigher

If CardNumber = 1 Then pbxCard2.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 2 Then pbxCard3.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 3 Then pbxCard4.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 4 Then pbxCard5.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 5 Then pbxCard6.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 6 Then pbxCard7.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 7 Then pbxCard8.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 8 Then pbxCard9.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

If CardNumber = 9 Then pbxCard10.ImageLocation = "C:\Users\Shaun Brett\Documents\Visual Studio 2005\Projects\Higher or Lower\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

' this is the line of code before i chanaged it If CardNumber = 9 Then pbxCard10.ImageLocation = "C:\Users\Shaun Brett\AppData\Local\Temporary Projects\Higher or Lower\Resources\a" & CStr(SelectedCards(CardNumber)) & ".bmp"

'did player get the selection right

If CardValue(CardNumber) < CardValue(CardNumber - 1) Then CardNumber = (CardNumber + 1) Else EndGame()

'did player get ALL the cards right

If CardNumber = 10 Then winner()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'set for btnNewGame only

TheSevenCards()

btnHigher.Enabled = True

btnLower.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

'show the winner he has won!

btnLower.Enabled = True

btnHigher.Enabled = True

BtnNewGame.Enabled = True

If WinCounter > 0 Then btnLower.Text = "WINNER"

If WinCounter < 0 Then btnLower.Text = ""

If WinCounter > 0 Then btnHigher.Text = "WINNER"

If WinCounter < 0 Then btnHigher.Text = ""

If WinCounter > 0 Then BtnNewGame.Text = "WINNER"

If WinCounter < 0 Then BtnNewGame.Text = ""

WinCounter = WinCounter * -1

FlashCounter = FlashCounter + 1

'reset game to start again.

If FlashCounter = 30 Then

btnLower.Text = "Lower"

btnHigher.Text = "Higher"

btnLower.Enabled = False

btnHigher.Enabled = False

BtnNewGame.Text = "New Game"

FlashCounter = 0

Timer1.Enabled = False

End If

End Sub

End Class





Re: Visual Basic Express Edition Where have my pictures gone?

ReneeC

Having a copy of them in the resources folder won't fix the problem. Goto

Main Menu | Project | Properties | Resources and add each picture with your name scheme.






Re: Visual Basic Express Edition Where have my pictures gone?

Shaun B

a big thanks to all those who assisted me with this thread, a particular thanks to reneec who gave me a solution, i did

as reneec suggested and used the picturebox1.image = my.resources.etc and the game published first time. unfortunately my lad played the game for about 10minutes before getting bored and went back to his playstation,

oh well! onwards and upwards

regards

shaun b