kkoser
asked on
image control madness 2 :)
List1 holds names of cards.(Randomly Drawn) i.e. AceofHearts, 2ofHearts, 3ofHearts, 4ofHearts, 5ofHearts.(Like a poker Hand). The images of the cards are in .jpg format on the hardrive. To Load an image into an image control i use
Text1.Text = List1.List(List1.ListIndex
Image1.picture = LoadPicture(app.path & "\" & Text1 & ".jpg")
This works ok.
Now the Goal here is to graphically represent the contents of List1 by opening a form(Form2), Adding image controls, then loading the controls with images from List1.
IdleMind gave me a great code snippet refer to : https://www.experts-exchange.com/questions/20962264/creating-an-image-control.html
it makes an array of image controls on the form. But i am having dificulty loading the images from a listbox.
now the question is: What would be the best way i can do this?
Any suggestions?
Be specific, what's the difficulty?
ASKER
well...to be specific..i am not sure how to do it the right way...i can load an image in the first imagebox i create but i cannot load the rest of the items in the listbox. i assume a for next is in order but....i am not sure of the right way to proccess the routine....:(
dim itm as listitem
for each itm in lstCards
Image1.picture = LoadPicture(app.path & "\" & List1.List(List1.ListIndex ) & ".jpg")
next itm
-EvadR
for each itm in lstCards
Image1.picture = LoadPicture(app.path & "\" & List1.List(List1.ListIndex
next itm
-EvadR
EvadR's on the right track. Since the image controls are in a control array the process needs to change to look like this:
Dim intCounter As Integer
For intCounter = 0 To (List1.ListCount - 1)
Image1(intCounter).Picture = LoadPicture(List1.List(int Counter))
Next
Also, whether or not you need to append App.Path to the begining of the listbox entry and ".jpg" (or some other extension) to the end will depend on whether you stored the full path and file extension in the listbox with the image names when you loaded them into the listbox.
Dim intCounter As Integer
For intCounter = 0 To (List1.ListCount - 1)
Image1(intCounter).Picture
Next
Also, whether or not you need to append App.Path to the begining of the listbox entry and ".jpg" (or some other extension) to the end will depend on whether you stored the full path and file extension in the listbox with the image names when you loaded them into the listbox.
ASKER
i think i got confused. i tried this;
Dim intCounter As Integer
For intCounter = 0 To (Form1.List1.ListCount - 1)
If Image1(0).Visible = False Then
Image1(0).Visible = True
Else
Load Image1(Image1.Count)
Image1(Image1.ubound).Visi ble = True
Image1(Image1.ubound).Left = Image1(0).Left + Image1.ubound * Image1(0).Width
Image1(intCounter).Picture = LoadPicture(Form1.List1.Li st(intCoun ter))
Image1(Image1.ubound).Top = Image1(0).Top
End If
Next intCounter
however it didn't work.
Am i doing it the right way? I feel like i am missing something. btw i put this in the On_Load of Form2. and to make it more simpler, the listbox has the entire path statement now. i.e C:\Images\AceofHearts.jpg, ,,. i hope that will help. Also thanx a lot for the help so far. i really appreciate it.:)
Dim intCounter As Integer
For intCounter = 0 To (Form1.List1.ListCount - 1)
If Image1(0).Visible = False Then
Image1(0).Visible = True
Else
Load Image1(Image1.Count)
Image1(Image1.ubound).Visi
Image1(Image1.ubound).Left
Image1(intCounter).Picture
Image1(Image1.ubound).Top = Image1(0).Top
End If
Next intCounter
however it didn't work.
Am i doing it the right way? I feel like i am missing something. btw i put this in the On_Load of Form2. and to make it more simpler, the listbox has the entire path statement now. i.e C:\Images\AceofHearts.jpg,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanx for the quick response. i will try it in a moment.
ASKER
still haven't tried it yet..wrapping stuff up for the weekend. but the goal is to make the form look like an actual "Hand" of cards.
Part1. It starts with a db with a little over 1500 cards. a listbox gets filled with the names of these cards.(lstCards) this listbox is constant ,as everything reverts back to the index number of this list.
Part2. The user selects from these cards their own personal "Deck".(Usually about 40-60 cards). This gets loaded into a different listbox.(lstDeck) on_click of this listbox sync's the listboxes together and fills an imagebox with the picture of this card. Form1.Image1.Picture = LoadPicture(lstDeck.list(l stCards.Li stIndex)No te: not the actual code but just to give you the idea.
Part3. as the online gameplay is started, you "Draw" 5 cards from your "Deck". Now i can fill the listbox with the cards, but what i wanted to do was, to create a form and on_load, it would graphically represent the items in the listbox.(Kind of like a "Hand of Cards")(lstHand). and this is where i am at...pulling my hair out on thissection of the app.:)
so the relationship here goes as follows: lstCards>lstDeck>lstHand>l stDiscard.
Part1. It starts with a db with a little over 1500 cards. a listbox gets filled with the names of these cards.(lstCards) this listbox is constant ,as everything reverts back to the index number of this list.
Part2. The user selects from these cards their own personal "Deck".(Usually about 40-60 cards). This gets loaded into a different listbox.(lstDeck) on_click of this listbox sync's the listboxes together and fills an imagebox with the picture of this card. Form1.Image1.Picture = LoadPicture(lstDeck.list(l
Part3. as the online gameplay is started, you "Draw" 5 cards from your "Deck". Now i can fill the listbox with the cards, but what i wanted to do was, to create a form and on_load, it would graphically represent the items in the listbox.(Kind of like a "Hand of Cards")(lstHand). and this is where i am at...pulling my hair out on thissection of the app.:)
so the relationship here goes as follows: lstCards>lstDeck>lstHand>l
ASKER
:)
This did the trick..
thanx a lot
Private Sub Form_Load()
Dim intCounter As Integer
Form1.lstHand.ListIndex = 0 - 1
For intCounter = 0 To (Form1.lstHand.ListCount - 1)
Form1.lstHand.ListIndex = Form1.lstHand.ListIndex + 1
If intCounter > 0 Then
Load Image1(intCounter)
End If
Image1(intCounter).Picture = LoadPicture(Form1.ImagePat h.Text)
Image1(intCounter).Left = Image1(0).Left + Image1.UBound * 350
Image1(intCounter).Top = Image1(0).Top
Image1(intCounter).Visible = True
Image1(intCounter).Tag = Form1.LstCards.ListIndex
Next intCounter
End Sub
This did the trick..
thanx a lot
Private Sub Form_Load()
Dim intCounter As Integer
Form1.lstHand.ListIndex = 0 - 1
For intCounter = 0 To (Form1.lstHand.ListCount - 1)
Form1.lstHand.ListIndex = Form1.lstHand.ListIndex + 1
If intCounter > 0 Then
Load Image1(intCounter)
End If
Image1(intCounter).Picture
Image1(intCounter).Left = Image1(0).Left + Image1.UBound * 350
Image1(intCounter).Top = Image1(0).Top
Image1(intCounter).Visible
Image1(intCounter).Tag = Form1.LstCards.ListIndex
Next intCounter
End Sub