Solved

form as control array

Posted on 1998-08-17
3
145 Views
Last Modified: 2010-04-30
Can a form be a control array?  I have tried using MyForm.Control(X).Show, but it doesn't seem to work.  And how does control collection work?
0
Comment
Question by:JaneKim
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1429232
When the form is shown, all the visible controls belonging to this form are shown. MyForm.Control(X).Show is invalid.
MyForm.show is valid.

If you want to do dynamically some form, do as follow :
     Dim frm as New Form

     frm.Show


The control collection works as other collections :

Samples :
Me.Controls.Count
Me.Controls(1).Caption = "&Caption"


0
 
LVL 14

Expert Comment

by:waty
ID: 1429233
Here is another sample :

Sub TraductForm(TheForm As Form)
   On Error GoTo ERROR_TraductForm
   
   Dim nI   As Integer
   
   TheForm.Caption = Traduction(CStr(TheForm.Caption))
   
   For nI = 0 To TheForm.Controls.Count - 1
   
      If TypeOf TheForm.Controls(nI) Is Label Then
         TheForm.Controls(nI).Caption = Traduction(CStr(TheForm.Controls(nI).Caption))
      ElseIf TypeOf TheForm.Controls(nI) Is Menu Then
         TheForm.Controls(nI).Caption = Traduction(CStr(TheForm.Controls(nI).Caption))
      ElseIf TypeOf TheForm.Controls(nI) Is CommandButton Then
         TheForm.Controls(nI).Caption = Traduction(CStr(TheForm.Controls(nI).Caption))
      ElseIf TypeOf TheForm.Controls(nI) Is Frame Then
         TheForm.Controls(nI).Caption = Traduction(CStr(TheForm.Controls(nI).Caption))
      ElseIf TypeOf TheForm.Controls(nI) Is CheckBox Then
         TheForm.Controls(nI).Caption = Traduction(CStr(TheForm.Controls(nI).Caption))
      ElseIf TypeOf TheForm.Controls(nI) Is OptionButton Then
         TheForm.Controls(nI).Caption = Traduction(CStr(TheForm.Controls(nI).Caption))
      End If
   Next
   
   Exit Sub
   
ERROR_TraductForm:
   Exit Sub
   
End Sub

0
 
LVL 1

Expert Comment

by:wford
ID: 1429234
you could do this too:
Dim FormX as Form

For Each FormX In Forms
    If Not FormX.Name = Me.Name Then FormX.show
Next

a form is a special type of control, it is a control, however you cannot make it an array, at least not as far as i know!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 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…

743 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

16 Experts available now in Live!

Get 1:1 Help Now