Solved

Simeple para. passing question --QUICK answer needed

Posted on 1998-12-07
4
181 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

623 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