Solved

Simeple para. passing question --QUICK answer needed

Posted on 1998-12-07
4
179 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
  • 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 50 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access query that references subform 5 47
Spell Check in VB6 13 127
clicking a shape in a frame array vb6 3 47
Help me. 3 60
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

830 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