Solved

Visual Basic 6 Pass a contol Array to Public Sub

Posted on 2015-02-22
5
152 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 45

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 45

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hovering effect 9 29
Visual Studio: built-in keystroke automation 2 23
Round a string to two digits 12 24
XML & .net 5 19
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now