Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simeple para. passing question --QUICK answer needed

Posted on 1998-12-07
4
Medium Priority
?
183 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 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

Technology Partners: 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

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…
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

772 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