Solved

form as control array

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

Title # Comments Views Activity
Validating VB6 Function 19 65
clicking a shape in a frame array vb6 3 46
VB6 ListBox Question 4 48
Collapse and expand table in Word 2010 2 32
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

860 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