Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Dynamically Create Textboxes, and Form Scrolling?

Posted on 2004-11-24
3
Medium Priority
?
171 Views
Last Modified: 2010-05-02
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?
0
Comment
Question by:Greggory
  • 2
3 Comments
 
LVL 7

Expert Comment

by:HoweverComma
ID: 12671221
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
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 500 total points
ID: 12671224
If you add 1 textbox and give it an index of 0 you can use its position to add new textboxes

Dim i As Integer

Private Sub Form_Load()
i = 1
End Sub

Private Sub Command1_Click()
Load Text1(i)
Text1(i).Top = Text1(i - 1).Top + Text1(i - 1).Height
Text1(i).Visible = True
i = i + 1
End Sub
0
 
LVL 7

Expert Comment

by:HoweverComma
ID: 12671226
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

581 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