Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Create Dynamically A Textbox Array


hi !
i need to take input from user in a textbox for No.of textfields he/she wants to generate.... i want to generate textfields according to the entry in the textbox and all the generated fields shud appear behind that textbox..can anyone tell me the right and exact code...i've tried ReDim but its not working for me..there's an error . Object variable without block variable not set..sorta error..can any one help me..i m posting code down.

Actually this is another textbox on which key_down event i m trying to do so.

If KeyCode = 13 Then
'Generate Fields according to this field's value
For i = 1 To CInt(txtNoOptions.Text)
ReDim Preserve txtHidden(i)
txtHidden(i).Top = txtQDesc.Top + i * 200
txtHidden(i).Left = txtNoOptions.Left


Next
End If


I've tried both by making an array of a textbox named as txtHidden on the form at design time and both by declaring at the general section like this
dim txtHidden() as TextBox ..but somebody help me




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
I Can Not Create A Textbox Dynamically.
I want to creat a textbox dynamically, what is wrong with following code? thanks

Code:


Private Sub Form_Load()
Dim tb As TextBox
tb.Top = 100
tb.Left = 200
tb.Width = 500
tb.Height = 300
tb.Visible = True
End Sub

Dynamically Create Multidimensional Array
hey guys, I've done a lot of reading and I've figured out a few things here, but I'm still getting stuck on something I'm trying.

For a little background information, the first piece of data is a tag number which I am going to put into a combo box and the rest of the data (which I have as just three items) are the pressures which these tags must be taken to. The number of pressures is variable depending on what the user puts into the text file....can be anything from 1 pressure to a large amount of pressures (this being the part thats stumping me)

basically what i'm trying to do is take in lines from a text file and store into an array. It starts out in the text file as:


Code:
1660 Tags, 5,10,15;
1680 Tags, 20,25,30;
First i read the data and split it by ";" into two array values.
Then i want to split it again so that I'll have a 2D array with each dimension storing data for the individual tag (in this case, an array 2x4). Once I get that far, I can take the values and do what I need to do with them.
Again, it could end up being more than 2D. The could enter 50 tag types with pressures for each one.

I hope I have explained this well enough that somebody knows what I am talking about. If not, i apologize and just let me know, I'll try to clarify it a little more.

Arrays have never been my strong point....thanks a million for any help.


Nick

Dynamically Create Control Array.
Hi guys, I am trying to dynamically create a control array of text boxes for my program, but I can't get it to work. My code is:


Code:
Dim WithEvents txtControl As TextBox
Dim countq As Integer

Private Sub cmd_forward_Click()
countq = countq + 1

For i = 0 To txt_quote_no.Text
If Not i = countq Then
txtControl(i).Visible = False
Else
txtControl(i).Visible = True
End If
Next i
End Sub

Private Sub txt_num_quotes_Change()
a = txt_num_quotes.Text
Dim txtControl(0 To a) As TextBox
For i = 0 To txt_num_quotes.Text
Set txtControl(i) = Controls.Add("VB.TextBox", "txtControl" & i)
txtControl(i).Left = 100
txtControl(i).Top = 600
txtControl(i).Width = 2535
txtControl(i).Height = 285
Next i
txtControl(0).Visible = True
countq = 1
lbl_quote_no = (countq) & "/" & (txt_num_quotes.Text + 1)
End Sub
A couple of errors I am getting: First of all, on my "Dim txtControl(0 To a) As TextBox" Line it says a constant value is required. Second of all, when I hard code in a constant and try to move to the next box, it says "Wrong value of arguments or invalid property assignment" on the line " txtControl(i).Visible = False" In the cmd_forward sub.

How can I allow a dynamic value to be assigned, and dynamically create a control array?

Any help would be appreciated.

Cheers, Gazler.

Edit I managed to solve the dynamic number of boxes by using reDim instead of Dim. Still have the second error though.

Dynamically Create Control Array
How could I create a control array at runtime? I want to create x picture boxes at runtime, inside another PictureBox. the inner picture boxes must be in a control array: pctWorms(x)
thanks

Dynamically Create A Control Array
I know how to create a dynamic cotrol (making a control at runtime), but how do I go about making a control array?

How To Dynamically Create CommandButton Array
Hi,

Can anybody tell me how to create Command Button array. dynamically..

My requireemnt is ..

I specify a number say '4'

the form should then contain 4*4 matrix of command butttons.

arranged in a proper order..

Thanks in advance,
Pradeep

Create Array Of Controls Dynamically
1)
I'm not sure what you are looking for, please specify.

2)
Insert a loop.

IE. if you wan't an operation to take 2 seconds for every execution.

Code:
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

private sub Test()
dim lngTime as long

lngtime = GetTickCount

'Your code

do while GetTickCount < lngTime + 2000 'The time is in mSeconds.
DoEvents
loop

end sub


3)
I would suggest that you search this forum for information about the bitmap datastructure. With this you should be able, using binary operation a file, to create small bitmaps images and load these into picture boxes.

How To Dynamically Create And Allocate An Array Of Controls
Hello

VB 6.0

The application I'm writing in one part of it should be able to create an array of checkboxes, textboxes and comboboxes depending on a number that the application has to calculate from some input.
The problem is that this number can go up to 500 for example, So it's very important to have it dynamic and create and position them dynamically. they should be divided in pages and each set of controls on a line.

How should i define these arrays? how to create them in the code and allocate the necessary memory? what is the best way to position them one below the other?

I appreciate any help in this regard

Thanks

Dynamically Adding Textbox Array
Hi,
I want to be able to start off with a blank form and depending on how many database fields are in a table, to dynamically add the textboxes to the form with the same name but as an array.
i can see the code that adds a textbox as


Code:
Dim mytextbox As Control

Private Sub Form_Load()

Set mytextbox = Form1.controls.Add("VB.textbox", "mytextbox", Form1) ' Form1 is the form name
mytextbox.Visible = True
' now just position it and size it

mytextbox.Top = 250 ' or whever you want it
mytextbox.Width = 2000 ' your width
mytextbox.Height = 200 ' or however tall you want it
mytextbox.Text = "I was created dynamically!"

End Sub
but how do you do it if you want the textboxes to be an array.

any help would be great.

Newbie Question: Create Control Array Dynamically
how to create a control array at runtime
i am confused

Code:
Static Segment(theLength - 1) As VB.Line
For i = 0 To theLength - 1
Set Segment(i) = Controls.Add("VB.Line", "What does this do")'what does this do
Segment(i).Visible = True
Segment(i).X1 = 0
Segment(i).y1 = 0
Segment(i).X2 = 0
Segment(i).y2 = 0
Next i

Create Date For A Month In Textbox With Array.
I have little project for my school for student attendance. What Iím doing now is each new month I have to create date in textbox manually depend on how many days in a month. For example in Feb, 2004 there are 29 days so I have to fill in textbox 29 times. I use DTPicker and textbox to do this with doubleclick even but itís only work for one textbox.

It is possible to create Textbox Array so when the month is changed it will create textbox as many as the day in that month.(of course with the date in it)

Here is the code

Private Sub Form_Load()
Dtpicker1.Visible = False
End Sub

Private Sub DTPicker1_DblClick()
txtDate.Text = DTPicker1.Value
DTPicker1.Visible = False
End Sub

Thanks.

Possible To Dynamically Create An Object Inside A Dynamically Created Object?
If I create a picture box dynamically, how do I go about dynamically creating an object in that picture box? So far everytime I attempt to dynamically create instances of the 2nd object (a shape), they show up in the orginal picture box instead of in the last one.

Dynamically Create A .exe
How can I create an executable from my program to assemble a group of files in to one file (I am making a file splitter). I can make the executable but it is telling it how many files there are and what they are called that I don't know how to do, without including some sort of config file. Any help? Thanks.

Dynamically Create Jpg
I need to, on the fly, create a jpg image that will be used on a webpage, basicly just a line graph. I can handle all the drawing, but i dont know where to draw to. That is, to allow me to save the GDI calls as a jpg or gif image, or even a bmp if need be.

Dynamically Create A Flexgrid
VB6.

Being a Flexgrid isn't an intrinsic control in VB, I need help on how to dynamically create one. I'm thinking it falls into the ActiveX category.

Dynamically Create XML From Excel VBA
Does anyone have an example I might be able to look at for creating and parsing XML from VBA?

Thanks in advance,

-Jeff

Dynamically Create A Form
I am using Access 2003 and would like to figure out how to create a form with a subform dynamically based on a predetermined set of parameters stroed in an excel spread sheet.

I am already able to create all the tables in this manner and would like to figure out how to move up to other objects. I saw the one post for creating databases, however I do not have VB here and I am unable to open it.

I would appreciate any help locating the information or id someone hase done this, I would like to see what you have tried.

Thank you,

Dynamically Create Own Eventhandlers
In runtime I create a couple of listboxes in a grid.
It works fine. I give then names in a lopp. Now i will declare handlers for them at the sam time so I can track user events.
Any idea how to do this?

Here is the code for creating
====================
Dim WithEvents cbo As ComboBox

'Adding combobox in runtime
For r = 1 To .Rows - 1

.row = r
.Col = 2
.RowHeight(r) = 315

Set cbo = Controls.Add("VB.ComboBox", "cbo" & r)
cbo.AddItem "Please Select Version"
cbo.AddItem "1.0"
cbo.AddItem "2.0"
cbo.AddItem "3.0"
cbo.Move .CellLeft + .Left, .CellTop + .Top, .CellWidth
cbo.ListIndex = 0
cbo.ForeColor = &HFF&
cbo.Visible = True
cbo.ZOrder (0)

'Declare function dynamic?
'public declare function name...

Next

How To Create Recordset Dynamically?
Hi.

I've created dynamically Datacombo. Now each one needs a recordset . So how to create and associate dynamically Recordset to the datacombo.

thanks

Dynamically Create Label
I tried using the following code to create a label:


Code:
Private Sub Form_Load()
Set lbl = Me.Controls.Add("VB.Label", "lbl")
End Sub
But it gives me the error "object cannot support this property or method".

I'm using VB 5, so is that the reason why its not working? If so, what can I do instead to make it work? THanks

Create Form Dynamically
Hi all,
How can I create a form Dynamically from within a class ?
(I need to create a dummy form in order to use it as a container to controls I need)

thanks,
adi

How To Create Database Dynamically
dear friends

how to create database during runtime.
can u just send me the sample code?

regards
Abhishek

Dynamically Create Shapes
Hi all,

I wonder if there is anyway to dynamically create a vb6 shape ("rect,square,circle") etc..

I mean something like this:

If condition then create shape1


Thanks very much,
zeid

Dynamically Create Files
Hi,
I am trying to write a script where I read from a master excel file and parse the data into multiple text files. This needs to be done dynamically depending on how many rows of data there are in the excel file. How do I dynamically assign file numbers to each new text file that I create? Here is the code I have come up with and I am stuck at this point:

This following code has a little bit of vbscript in it. Its not classic vb. Its a piece of code from a software testing tool .


Code:
introw = 2
Do Until objExcel.Cells(introw,7).Value = ""
Open "C:sample.txt" for Output As #?
Print #?, "U=" & Format(objExcel.Cells(introw,1).Value,">") &"&"
If objExcel.Cells(introw,2).Value = "p1" then
Print#?, "P="& Format(objExcel.Cells(introw,2).Value,">") &"&"
else
Print#?, "P="& objExcel.Cells(introw,2).Value &"&"
end if
Print#?, "Q="& objExcel.Cells(introw,3).Value &"&"
Print#?, "B="& Format(objExcel.Cells(introw,4).Value,"mm/yyyy")&"&"
Print#?, "S="& Format(objExcel.Cells(introw,5).Value,"mm/dd/yyyy hh:nn" &"&"
Print#?, "E="& Format(objExcel.Cells(introw,6).Value,"mm/dd/yyyy hh:nn") &"&"
Print#?, "T="& objExcel.Cells(introw,7).Value &"&"
Close #?
introw = introw + 1
Loop

Dynamically Create Email Via VB
Hi All,

Is it possible to create an email with VB and send it via locally installed email program (Outlook 2000). If so, how?

mccreaso

Dynamically Create Enums
Lets say I retrieve 3 values(lets say usernames) from a database table in a loop from a function in a class

I would want them to be populated in ENUM dynamically ...The reason I want in that way is becuase I would write another function where I pass Enum as paramater to the function which will be exposed to the client

so from the client the function exposes the 3 names populated in ENUM...???

Is It Possible To Dynamically Create A Reference?
Im programming VBA in MSProject at the moment, and basically im creating a template with a lot of macros. Some of them are quite complicated and need references of certain objects (Excel, Access, MSCommonDialog etc.)

As existing planning files are hard to copy to new template files my boss wants to be able to import the mod, cls and frm files. This is actually possible in MSProject, but the much needed references are not made.

My question is:

Is it possible to write a function that checks if the references exist and if not create them on the fly?

Thanx in advance!

Create Control Dynamically
Hi all,

i would like to build a function to create an array of commandbuttons for the caller?

e.g. CreateButton(cmd as commonbutton)

Caller passs in command1(0) to the above function. How can i create an array of command buttons from command1(0).

Thanks!

Create Table Dynamically, Is It Right?
Dear Friends,

Greetings! I found a previous post by TheBao. as follows:


Code:
Dim con As ADODB.Connection

Private Sub Command1_Click()
Dim strSQL As String
'create table
strSQL = "CREATE TABLE " & Text1.Text & "(C1 INT PRIMARY KEY)"
con.Execute strSQL
End Sub

Private Sub Form_Load()
'connect to Northwind database on local machine
Set con = New ADODB.Connection
With con
.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Northwind;Data Source=(local)"
.Open
End With
End Sub



Is this code can help me create a table at runtime because I am afraid creating table in a database of MS Access might need ADOX?

I wish to ask also if I have a table acting a template for instantiation, I wish to create a new table of exactly the same schema of this template and import text data from a text file of a predefined delimited structure into this newly generated table. How can I code this? Any idea.

Previously, I use DoCmd.TextTransfer method to import the text as a temporary table and then delete it after all necessary data have gone into the true tables. But I faced the database or object read only error for unknown reason.

Can you help help please.

Thank you very much. Wish you every happiness from programming.

Dynamically Create Forms
I have this project where people sign up for a conference on my site. I am looking for code (or concept) so that I can dynamically create forms when a user is registering on my site and needs additional forms to register additional people with.

I use .asp pages.

Writing in VBScript.

I know this probably belongs in the other forums but this section is so active!

Snippets are welcome.

Thanks!

Dynamically Create Forms
I'm making an AIM-like program and I would like to make a new chat form each time you message someone else. i.e. when someone messages you a window will popup and you'll be able to chat, when someone else messages you a second copy of the first window will appear with that person's message. All I need to know is how you make the same *.frm file appear twice. Any help is greatly appreciated.

-thanks
Otto

How To Dynamically Create MDI Clients
I have a ActiveX DLL component that contains a standard Form. I want to make this form a MDI_Child in my main project. It is not possible by simply setting the From MDIChild property to TRUE. I've tried some stuff with the SetParent API. This solves a bit of the problem, but the behaviour of the form is not quiet like a regular MDI_Child.

Does anybody has a working solution.

Thanks,

Erik Kratz

Create A Database Dynamically
Is it possible to create a database using codes only. I would like to create a program which looks like a wizard in which the user will set the name of the database, the fieldnames, as well as their corresponding data type and size. Please help, thanks in advance

Create Button Dynamically
hi everybody
i work in the past (4 years ago) with vb6 and from that time i work with flash
but now i need somehelp to do a small vb6 application
my question is : can i create button only with script
i want to put a button on the scene and each time i drag and drop the button i put a new button
any help
thank you

How To Create Form Dynamically
Will anyone tell me how to create forms dynamically like text box or an other objects? I have created forms using Control array. But how can I create them using object variable? I do not know the proper library name for the form object to add it dynamically. If any one knows then he/she please help me. Thank you.
Nirmalya Chakraborty

HOW TO CREATE FORMS DYNAMICALLY
Hi,

      I have a doubt. In my project I need to create vb forms dynamically. That too those forms should be resized. How to do this in VB. Plz.... I need this. Any one help me.


suma.n

How To Create A Dbf File Dynamically?
Hi ,
 Is there anyway that i can create a dbf file dynamically without usin excel in visual basic?

thanks
Karunya

Dynamically Create Variables
I want to dynamically create variables by going through a loop. For example I want to create variables as follows. I know how to loop it just how to create the variables is the problem

Code:
Dim NewControl1 As New clsAutoText
Dim NewControl2 As New clsAutoText
Dim NewControl3 As New clsAutoText
Dim NewControl4 As New clsAutoText
Dim NewControl5 As New clsAutoText


Any suggestions ?






A VB turned PHP geek


Edited by - paCkeTroUTer on 11/16/2002 4:06:01 AM

How To Create Controls Dynamically In VBA
Hi the program is basically created using an existing form to populate controls using textbox,i have created one function to do it,but the error throws controls can only be created or deleted in Design View, I would like to know how to solve this problem?Thanks
Option Compare Database

Private Sub btnOpen_Click()
On Error GoTo Err_btnOpen_Click

Dim frm As New Form_Test ' Form named called Test



'Testing only
MsgBox frm.Name


Dim intNumOfRecords As Integer
    Dim i As Integer
    i = 1
    Dim ctlText As Control
    Dim intDataX As Integer
    Dim intDataY As Integer
    
    Dim intDataHeight As Integer
    Dim intDataWidth As Integer
    Dim intDataTop As Integer
    Dim intDataLefy As Integer
    
    Dim x As Integer
    Dim y As Integer
    
    
    intDataWidth = 2000
    intDataHeight = 250
    intDataTop = 100
    intDataLeft = 100
    
    intNumOfRecords = 8
    
    For i = 1 To intNumOfRecords

    Set ctlText = CreateControl(frm.Name, acTextBox, acDetail)
     
    With ctlText
        .Name = "TextBox" & i
        .Left = intDataLeft
        .Top = intDataTop
        .Width = intDataWidth
        .Height = intDataHeight
        .Visible = True
    End With


    
    intDataTop = intDataTop + 400
    
                             
    Next i

'Set frm = Forms("Test")

DoCmd.OpenForm "Test"
'frm.Visible = True


Exit_btnOpen_Click:
    Exit Sub

Err_btnOpen_Click:
    MsgBox Err.Description
    Resume Exit_btnOpen_Click
    
End Sub

Create Controls Dynamically
In know creating controls at run time in VB through control array. But for this we have to create on copy at designtime.Instead is this possible to create at run time

Dynamically Create A Flexgrid
VB6.

I'm guessing I can't dynamically create flexgrids like intrinsic VB controls such as a textbox.

Where do I start?

Create Font Dynamically
I would like to create an application which uses font from my application itself, it means when my app starts, it creates a font and registers to system, so that my app can use that font. After app ends, that font is removed.

Could it available ?

Please help me to give an idea or solution to solve it.

Thank you vey much.

Dynamically Create Form At Runtime
Hi,

what I want is simple, I just can't figure out how to achieve it:

I want to create a new Form at runtime and fill it with controls.

I need to write a Script for a application. The Application calls a "script.vbs" and I can choose "MsgBox("Hallo")" to interact with the user, but now I want a real Form with controls. Because I can just use this script, I cannot design the form at designtime with VB6, or is it possible to load the Form from a "Form1.frm" file?

I found information on creating controls at runtime. The only thing I need is a Form. "set myForm = CreateObject("Form")" does not do the trick, why?
Anyone with a hint?

Thank you!

Create Textfiles Dynamically In A Sub-folder
Hello....

My application code is stored in "C:codeProgram Files". The other sub-folder in the "code" directory are "Data" and "Temp". The sub-folder "Data" has folders named Job_Data, UpOut_Data and FamilyData inside it.

One particular peice of code is this:

Dim fso1 As New FileSystemObject, fil1 As TextStream
Randomize
sFullFname = "..DataFamilyDataFullShot_" & Date$ & ".txt"
Set fil1 = fso1.CreateTextFile(sFullFname, True)
fil1.Close

I am trying to create a text file named "FullShot_10-04-2003.txt" in the
FamilyData subdirectory. But this peice of code returns

"Run-time error '76': Path not found"

I am using the same piece of code in another part of the program (to create text files in the Job_Data and the UpOut_Data folders) too and it works intermittently. I cannot find why it works sometime and doesn't at other times. When it does not work, I just exit the code and run it again to get it to work. Can someone guide me in this?

Dynamically Create Controls At Runtime
Hi Guys and Gals,
Pardon me for the complete novice attitude on this subject, but I have never attempted what I am trying to attempt here. What I want to do is basically RECREATE the VB IDE environment for my end user (in a very limited fashion, of course). On one screen, I will have a blank form with a components palatte, which will allow my clients to click and drag certain components onto the form and modify their properties. For example, create a text box, combo box, slider, or listbox exactly HERE on the form and allow them to set the possible values for the listbox/combobox, etc. I will then store information about each control in a database and generate that control on a form for them, allowing data input. My question is, has anyone attempted this before, and what are the pitfalls I should avoid and does anyone have a link to an example of how this has been done? Thanks everyone!

Dynamically Create A Form And Controls...
Ok.. i have a real problem. I would like to be able to dynamically add a form to a project and add somewhere between 2 and 6 textboxes on that form (depending on the user's selection, to hold about a single row each). once the form and controls are created i can handle the rest, it's just that i've never done something like this before.

I'm having a hard time here, can some one point me in the right direction?

SStab - How Create Controls Dynamically
Hello people
In a vbp project I use a SSTab Control (Microsoft Tabbed Dialog 6.0 (SP6)
As you know, if I want to dynamically create say three tabs I can use the property TabCaption. For example:
For J = 0 to 2
SStab1.TabCaption(J) = "Tab numero" & J"
Next
Doing like this, the SStab will have three tabs whose captions are : Tab number 0, Tab number 1, Tab number 2).
Now I want to dynamically create also a command (say cmdButton) so that on the tab(0) I put the cmd(Button(0), on the Tab 1 the cmdButton(1) etc.
Do you know how to do that?

I don't know whether I explained the question well.
Thank you for yr kind collaboration.
Regards
TdP

Dynamically Create Control Instances
Does anyone how to create control instances dynamically in VB6, from a control container that is already on the form, basically I want to create a scroller pane where users can scroll down the list of items.

i.e

Code:
Frame - (with scrollbar)
Container(0) - (maybe a picture box or another frame)
Label(0)
TextBox(0)
Container(1) - (this control is created dynamically copying 0)
Label(1)
TextBox(1)

any ideas or is there a control in vb already capable of doing this?

Create Report Dynamically Without Using Crystal
Hi All !

we are using visual .net and wish to create report dynamically and send data to crystal viewer. Our structure is in such a way that we don't have any fixed number of columns , however we wish to create a reaport which acomodates all the columns selected by user at run time, and create report accordingly.

your help is appreciated.

Thanks

Raj Dhawan

Copyright © 2005-08 www.BigResource.com, All rights reserved