?
Solved

Image Control Array Help

Posted on 2003-03-03
13
Medium Priority
?
179 Views
Last Modified: 2010-05-01
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
Comment
Question by:ragnorus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8061919
on which line?

try:
set imgHand(i).Picture = LoadPicture(App.Path + "images\" + i + ".jpg")
0
 
LVL 2

Accepted Solution

by:
Hossy earned 150 total points
ID: 8061921
What line is the debugger stopping on?
0
 
LVL 2

Expert Comment

by:Hossy
ID: 8061932
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.

 
LVL 6

Expert Comment

by:GPrentice00
ID: 8061940
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
 
LVL 2

Expert Comment

by:Hossy
ID: 8061954
Instead of the + symbol, try &:

imgHand(i).Picture = LoadPicture(App.Path & "images\" & i & ".jpg")
0
 
LVL 2

Expert Comment

by:Hossy
ID: 8061961
+ is used for addition, & is used for concatenation
0
 

Author Comment

by:ragnorus
ID: 8061971
the debugger points to Load imgHand(i)
0
 

Author Comment

by:ragnorus
ID: 8061977
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
 

Author Comment

by:ragnorus
ID: 8061995
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
 

Author Comment

by:ragnorus
ID: 8061999
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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8062001
& and + sometimes have behave differently.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8062015
shouldn't you initialize i to 1 (because normally the instance of imgHand on the form is set to 0) ?
0
 

Author Comment

by:ragnorus
ID: 8062150
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question