Results 1 to 3 of 3

Thread: how to create dynamic text boxes in a form

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    1

    how to create dynamic text boxes in a form

    i want to create given number of textboxes during runtime how to write code for it

    kavimani

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: how to create dynamic text boxes in a form

    Welcome to the forums

    Here's a simple sample:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
      AddTextBoxes 5
    End Sub
    
    Private Sub AddTextBoxes(number As Integer)
      Static x As Single
      
      Dim i As Integer
      
      Dim txt As TextBox
      
      For i = 1 To number
        Set txt = Me.Controls.Add("VB.TextBox", "txt" & i)
        
        If x = 0 Then
          x = 200
        Else
          x = x + 200 + 200
        End If
        
        txt.Move 200, x, 2000, 200
        txt.Visible = True
        
        Set txt = Nothing
      Next i
    End Sub

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to create dynamic text boxes in a form

    Here is an example to play with.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width