Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Add Form Controls at Run-time
Author:
Deep
Website:
http://www.geocities.com/basudip_in/download
Submitted:
8/12/2006
Version:
VB6
Compatibility:
VB6
Category:
Controls
Views:
21305
Add TextBox dynamically during runtime.
Declarations:
Place 2 command button on the form
Code:
Private txtObject As TextBox Private tValue As Long, cIndx As Integer, ctrlName As String Private Sub Command1_Click() cIndx = cIndx + 1 tValue = tValue + 400 ctrlName = "DynTxtBx" & CStr(cIndx) Set txtObject = Form1.Controls.Add("VB.TextBox", ctrlName) With txtObject .Visible = True .Left = 250 .Width = 4000 .Height = 250 .Top = tValue .Text = "This is a dynamically created TextBox No." & CStr(cIndx) End With If Not Command2.Enabled Then Command2.Enabled = True End Sub Private Sub Command2_Click() Form1.Controls.Remove ctrlName cIndx = cIndx - 1: tValue = tValue - 400 ctrlName = "DynTxtBx" & CStr(cIndx) If cIndx = 0 Then Command2.Enabled = False End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement