Solved

Visual Basic 6 Pass a contol Array to Public Sub

Posted on 2015-02-22
5
156 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 47

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 47

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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