• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Image Control Array Help

I am trying to dynamically create image controls by a loop with an array, but I keep getting: "Type Mismatch" in the debugger.  Here is the code:

Private Sub mnuNewGame_Click()
    varLastLeft = 16
    i = 0
    While i <= 10
        Load imgHand(i)
        imgHand(i).Visible = True
        imgHand(i).Left = varLastLeft + 89
        imgHand(i).Top = 456
        imgHand(i).Width = 65
        imgHand(i).Height = 89
        imgHand(i).Picture = LoadPicture(App.Path + "images\" + i + ".jpg")
        i = i + 1
    Wend
End Sub

Thanks :)
0
ragnorus
Asked:
ragnorus
  • 5
  • 4
  • 3
  • +1
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
on which line?

try:
set imgHand(i).Picture = LoadPicture(App.Path + "images\" + i + ".jpg")
0
 
HossyCommented:
What line is the debugger stopping on?
0
 
HossyCommented:
What line is the debugger stopping on?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
GPrentice00Commented:
I get a type mismatch just trying to make your string:
To fix:

app.path + "images\" + cstr(i) + ".jpg"

You probably also wanted it to be:
app.path + "\images\" + cstr(i) + ".jpg"

0
 
HossyCommented:
Instead of the + symbol, try &:

imgHand(i).Picture = LoadPicture(App.Path & "images\" & i & ".jpg")
0
 
HossyCommented:
+ is used for addition, & is used for concatenation
0
 
ragnorusAuthor Commented:
the debugger points to Load imgHand(i)
0
 
ragnorusAuthor Commented:
Well for the + or & suggestion, I read from this book that either works for concatenation, just that & is more conventional.  I am used to + for javascript, so I'm sticking with it..until it's really a problem (ha ha)

Thanks for the help
0
 
ragnorusAuthor Commented:
Oh for varLastLeft = 16..don't mind that.  At one point, I thought it was the imgHand(i).left that was causing the problem.
0
 
ragnorusAuthor Commented:
Oh for varLastLeft = 16..don't mind that.  At one point, I thought it was the imgHand(i).left that was causing the problem.
0
 
Éric MoreauSenior .Net ConsultantCommented:
& and + sometimes have behave differently.
0
 
Éric MoreauSenior .Net ConsultantCommented:
shouldn't you initialize i to 1 (because normally the instance of imgHand on the form is set to 0) ?
0
 
ragnorusAuthor Commented:
Hossy and emoreau, you were right.  I got the problem fixed..and it was mainly some error I made when making the object (it wasn't declared as an array yet!).  Then, that new type mismatch error came up, and I had to use &.

Thanks for the help guys. :)
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now