Create Run Time controls

I'm developing a project in visual basic 6.
I want to create a form with author information like name, qualification, article etc.
I have created one frame in a form and in this frame I placed labels and textboxes for entering author information.
like the following

Name    Qualification     Article
textbox   textbox           textbox

I don't know how many author entries are there for a record.
so I want to add one command 'Add' next to the frame, to add the next textboxes for entering the  next author's values and so on.

like

Name    Qualification     Article
textbox   textbox           textbox
textbox   textbox           textbox
Name    Qualification     Article
textbox   textbox           textbox
:
:
:


and when the list grows out of the given  frame size then I want to add one vertical scroll  bar so that user can scroll up and down to see the textboxes and can fill up the values.

How this is possible in visual basic.
anyone have any idea

thanks in advance

SS
ssonia27Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NBrownohCommented:
to show you how  to create things at runtime, i did this with a command button named command1, they have to have an index, so this starts at 1:
    Load Command1(Command1.Count + 1)
    TMany = Command1.Count
    Command1(TMany).Top = Command1(TMany - 1).Top + Command1(TMany - 1).Height + 120
    Command1(TMany).Visible = True

but that in a button and click away.

then to check if its gone out of the screen there, just do somethin like:
if yourlasttextbox.height + yourlasttextbox.top >= yourform.height then
  scrollbar1.visible = true
end if

change the names as recquired.
0
RimvisCommented:
NBrownoh is basicaly right. You need to create control array. First memberof array must be allready placed at design time, others can be added at run time

Save following code as Form1.frm and include it in your project, it includes crolling code to:


VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   3540
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3675
   LinkTopic       =   "Form1"
   ScaleHeight     =   3540
   ScaleWidth      =   3675
   StartUpPosition =   3  'Windows Default
   Begin VB.PictureBox picBoxes
      BorderStyle     =   0  'None
      Height          =   2895
      Left            =   240
      ScaleHeight     =   2895
      ScaleWidth      =   3255
      TabIndex        =   4
      Top             =   480
      Width           =   3255
      Begin VB.VScrollBar vscBoxes
         Height          =   2895
         Left            =   2880
         Max             =   0
         TabIndex        =   8
         Top             =   0
         Visible         =   0   'False
         Width           =   255
      End
      Begin VB.TextBox txtName
         Height          =   285
         Index           =   0
         Left            =   0
         TabIndex        =   7
         Text            =   "0"
         Top             =   0
         Width           =   735
      End
      Begin VB.TextBox txtQualification
         Height          =   285
         Index           =   0
         Left            =   840
         TabIndex        =   6
         Top             =   0
         Width           =   975
      End
      Begin VB.TextBox txtArticle
         Height          =   285
         Index           =   0
         Left            =   1920
         TabIndex        =   5
         Top             =   0
         Width           =   855
      End
   End
   Begin VB.CommandButton cmdAdd
      Caption         =   "Add"
      Height          =   255
      Left            =   3000
      TabIndex        =   3
      Top             =   120
      Width           =   495
   End
   Begin VB.Label Label3
      Caption         =   "Article"
      Height          =   255
      Left            =   2160
      TabIndex        =   2
      Top             =   120
      Width           =   1095
   End
   Begin VB.Label Label2
      Caption         =   "Qualification"
      Height          =   255
      Left            =   1080
      TabIndex        =   1
      Top             =   120
      Width           =   1215
   End
   Begin VB.Label Label1
      Caption         =   "Name"
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   1335
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private iItems As Integer

Private Sub cmdAdd_Click()
    iItems = iItems + 1
    Load txtName(iItems)
    txtName(iItems).Top = txtName(iItems - 1).Top + txtName(iItems - 1).Height + 80
    txtName(iItems).Visible = True
    Load txtQualification(iItems)
    txtQualification(iItems).Top = txtQualification(iItems - 1).Top + txtQualification(iItems - 1).Height + 80
    txtQualification(iItems).Visible = True
    Load txtArticle(iItems)
    txtArticle(iItems).Top = txtArticle(iItems - 1).Top + txtArticle(iItems - 1).Height + 80
    txtArticle(iItems).Visible = True
   
    txtName(iItems) = iItems
   
    If txtName(iItems).Top + txtName(iItems).Height > picBoxes.Height Then
        vscBoxes.Visible = True
        vscBoxes.Max = vscBoxes.Max + 1
    End If
   
   
End Sub

Private Sub vscBoxes_Change()
    Dim i As Integer
    For i = 0 To iItems
        txtName(i).Top = (txtName(0).Height + 80) * (i - vscBoxes.Value)
        txtQualification(i).Top = txtName(i).Top
        txtArticle(i).Top = txtName(i).Top
    Next i
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ssonia27Author Commented:
thanks Rimvis It seems that my porblem will be solved by this code
i'll go through it and then tell you.
thanks NBrownoh,  is also right and telling the same idea for addign runtime controls

thanks

SS
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.