Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simeple para. passing question --QUICK answer needed

Posted on 1998-12-07
4
Medium Priority
?
182 Views
Last Modified: 2010-05-03
I am tring to pass a Image() to a sub? but I can't seem to get to syntax right.So How do you do this.
image1()

Private Sub Image1_Click(Index As Integer)
    getImageArry Index, Label1, Image1
End Sub

Sub getImageArry(num As Integer, lbl As Label, img() As Image)
    lbl = img(num).Name & "(" & num & ")"
End Sub

I am getting "Type mismatch: array or user defined type expected. Help and a sample of code will be appricieted.
HK

(this is just a test code, I attempted doing something like this in my program but I run in to the same problem
0
Comment
Question by:Hans_Klose
[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
  • 2
4 Comments
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1448570
Is Image1 and Image Control, or an array of Image Controls?  Give this a try, it Image1 is a control array.

Private Sub Image1_Click(Index As Integer)
    getImageArry Index, Label1, Image1(Index)
End Sub

Sub getImageArry(num As Integer, lbl As Label, img As Image)
    lbl = img.Name & "(" & num & ")"
End Sub

If Image1 is not a control array, try this.

Private Sub Image1_Click(Index As Integer)
    getImageArry Index, Label1, Image1
End Sub

Sub getImageArry(num As Integer, lbl As Label, img As Image)
    lbl = img.Name & "(" & num & ")"
End Sub

Good Luck,
Martin
0
 
LVL 2

Accepted Solution

by:
trillo earned 150 total points
ID: 1448571
When passing arrays of objects or user defined types, you MUST use a variant to recieve the object. When passing an array to a variant object, you also must not supply any index:

Private Sub getImageArry(num As Integer, lbl As Label, img As Variant)
    lbl = img(num).Name & "(" & num & ")"
End Sub


Trillo
0
 
LVL 1

Author Comment

by:Hans_Klose
ID: 1448572
I am a c++ and Java programmer, and I run across this while makeing a quick prototype. Do I need to cast it
0
 
LVL 2

Expert Comment

by:trillo
ID: 1448573
No, In VB castings are the most of the times not necesary, altouugh its useful in some cases: Example...

Dim s1, s2 as string
dim i as Integer
s1 = "123"
s2 = ""
i = s1       // no error, no casting needed
i = s2       // error casting needed
i = CInt(s2) // No error, casting applied
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

721 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