Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2006, 11:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Adding Text boxes on run time

I created a control array on a text box. I have one during design time. What I am trying to do is when a user clicks the add command button, another box will display below the text box. I can't seem to get the code straight. I will be able to get it to display if I iterate through the control array. What I am trying to do is to pass the parameters of the previous text box top position and the index to the sub routine so I can just load one text box. Here is my code below. I appreciate whatever help you can give.

Thanks

txtFlightDepartDate is the object and 0 should be the index. I have to figure out to how to get the index property of the text box at run time.

Call LoadControls(Me.txtFlightDepartDate,0)


Here is the sub routine I pass the parameters to.


Public Sub LoadControls(obj As Object, intCounter)

            intmaxidx = intCounter + 1
            obj(intmaxidx).Top = obj(intCounter).Top + _
            (obj(intCounter).Index * 400)
            obj(intmaxidx).Visible = True
            Load obj(intmaxidx)


End Sub

 
Old March 31st, 2006, 03:32 PM
Authorized User
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mrafaqi Send a message via Yahoo to mrafaqi
Default

hi,

here is way and i think probably it would work for u. u even don't have to creat a control array. you have to dimension just 2 local variable to store the top position of recently added textbox and a textbox Type Object to store the reference. at button click just create a text box as

Dim tbTextBox as System.Windows.Forms.TextBox
'Initialize this position variable with top of 15
Dim iPosition as Integer = 15

'Your Add Method or Event Handler
Private sub Add()
   tbTextBox = new System.Windows.Forms.TextBox
   'Add code to add this to container
   iPosition = tbTextBox.Top
End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding User Forms at Run time RichRansom BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 May 30th, 2008 11:49 AM
Cannot reference text box added at run time adman Beginning VB 6 5 September 19th, 2007 02:24 AM
Adding button at run time msathyaprasad90 ASP.NET 1.0 and 1.1 Professional 8 August 9th, 2006 11:05 PM
Adding new field to a database table in run time dotnet cat ASP.NET 1.0 and 1.1 Basics 1 October 6th, 2005 01:36 PM
Adding controls at run-time !! kishore_peddi C# 0 October 13th, 2003 06:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.