?
Solved

Visual Basic 6 Pass a contol Array to Public Sub

Posted on 2015-02-22
5
Medium Priority
?
158 Views
Last Modified: 2015-03-03
Hi -
I am trying to create a public Sub that will be able to access controls on different forms. I get a type mismatch when I try to run it. The control is a label in a control array.

See below...

(This is my modual)
Public Sub LoadNumbers(ByRef activeControl As Control)
Dim I As Long
  For I = 1 To 7
  Dim newControl As Control
    Load activeControl .lblArrPlaceHolder(I)
  Set newControl = activeControl .lblArrPlaceHolder(I)
    With activeControl .lblArrPlaceHolder(I)
      .Width = 855
      .Height = 615
      .FontBold = True
      .FontSize = 25
      .Alignment = 2
      .BackStyle = 0
      .BorderStyle = 0
      .Top = 6000
      .ZOrder 0
      Dim b As Integer
      b = I + 2
     .Left = 1600 * I
     .Caption = I
     .Visible = True
    End With
  Next

(On the form)
Private Sub cmdPickNumbers_Click()
LoadNumbers (frm649.lblArrPlaceHolder(0))
End Sub
0
Comment
Question by:doctor069
[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
  • 3
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40624821
Is this supposed to be VB6 or VB.Net?
0
 

Author Comment

by:doctor069
ID: 40624830
VB6 - Old I know
0
 

Accepted Solution

by:
doctor069 earned 0 total points
ID: 40624837
Got it. Changed as control to as Variant
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40624845
Given a control array called Text1

Usage: passit Text1
Public Sub passit(carr As Variant)
MsgBox carr(0)
MsgBox carr(1)
End Sub

Open in new window

0
 

Author Closing Comment

by:doctor069
ID: 40641458
Solved the issue
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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
Course of the Month14 days, 11 hours 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