Solved

form as control array

Posted on 1998-08-17
3
150 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 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