[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Visual Basic 6 Pass a contol Array to Public Sub

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
doctor069
Asked:
doctor069
  • 3
  • 2
1 Solution
 
Martin LissRetired ProgrammerCommented:
Is this supposed to be VB6 or VB.Net?
0
 
doctor069Author Commented:
VB6 - Old I know
0
 
doctor069Author Commented:
Got it. Changed as control to as Variant
0
 
Martin LissRetired ProgrammerCommented:
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
 
doctor069Author Commented:
Solved the issue
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now