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
Solved

Visual Basic 6 Pass a contol Array to Public Sub

Posted on 2015-02-22
5
155 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
  • 3
  • 2
5 Comments
 
LVL 46

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 46

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
which modules are active in VB6 project? 6 40
How to limit User Input 2 27
Using data from certificate to re-create certificate programmatically 3 25
Where is this file? 3 25
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 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…

808 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