Link to home
Start Free TrialLog in
Avatar of Greggory
Greggory

asked on

Dynamically Create Textboxes, and Form Scrolling?

I have a program that asks for the number of transaction that happened. I would like it to be able to handle most situtations, but I don't know how many input boxes to have by default. More than likely, it will never be more than 10. I found a form scrolling sample and added rows of text boxes. I then made the text boxes invisible and changed the form scrolling thing to only check visible controls. That way, when the text boxes are invisible, the scroll bar goes away. The problem is, with many text boxes, the scrolling is slow and choppy. Some controls scroll up faster than others, so the form gets distorted a little. Is there a way to dynamically create text boxes when they are needed or is there a better way to get as many as I need?
Avatar of HoweverComma
HoweverComma

Starting in VB6 you can add controls at runtim with this code. Pretty simple

Private WithEvents txtNew As VB.TextBox

Private Sub cmdNewUpDown_Click()

  Set txtNew = Controls.Add("VB.TextBox", "TextDynamic")
  txtNew.Text = "New TextBox"
  txtNew.Visible = True
 
End Sub

Private Sub txtNew_KeyPress(KeyAscii As Integer)
  KeyAscii = KeyAscii - 1
End Sub
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As a sidenote you would probably be better off using a FlexGrid control.
Then you don't have to worry until i think 65K entries.... Never hit the limitation using it.