?
Solved

creating buttons in the run time

Posted on 1999-11-03
3
Medium Priority
?
131 Views
Last Modified: 2010-05-02
By coding can I create Command buttons in the run time for example when type 10 in a text box, 10 command buttons will be created in the form…
0
Comment
Question by:merci
3 Comments
 
LVL 3

Accepted Solution

by:
Gordonp earned 40 total points
ID: 2179754
Yes!

If your using VB6 you can use the add method on the controls collection

Form1.Controls.Add "CommandButton"...

see help for exact parameters etc.

or...

in vb4-5 etc.

use a control array
only create one commandbutton with index 0 at design time then at runtime

Load Command1(<NextIndex Value>)
Command1.Visible = True
set up properties and position

Hope this helps

Gordon
0
 
LVL 3

Expert Comment

by:jjbyers
ID: 2179755
Yes you can recreate command buttons in the runtime. Below is a sample project.

Create a new Standard EXE project.
Add a textbox called text1.
Add a commandbutton call command1
Change the Index property of the commandbutton to 0
Add the following code to the form

Private Sub Command1_Click(Index As Integer)
Dim liCnt As Integer
  Select Case Index
    Case 0
      For liCnt = Command1.UBound + 1 To Command1.UBound + Val(Text1) - 1
        Load Command1(liCnt)
        Command1(liCnt).Visible = True
        Command1(liCnt).Top = Command1(liCnt - 1).Top + Command1(liCnt - 1).Height
      Next liCnt
  End Select
End Sub

Hope this helps.
0
 

Author Comment

by:merci
ID: 2191888
Thanks, That excatly what i wanted, Also Thanks "jjbyers" for your comments..
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
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…

598 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