Creating Forms w/Code

blabore
01-31-2002, 10:45 AM
I'm creating a VB front end for a database application, and was wondering if anyone knew of a way to automatically create forms based on information in a text file, etc. Basically, I'd like to create an application that could read information from a text file, then create a VB form with controls based on data in the file. I could then add the form to another project. Any ideas?

Thinker
01-31-2002, 11:11 AM
The automatic in "automatically create forms based on information
in a text file" means you write the program to create the form.
I expect you meant something that someone else has already
written. I doubt that exists, and even if it did, it probably wouldn't
work the way you want it to.

If I were going to do this, I would spend a great deal of time
looking at .FRM files (in notepad) that were in the format of the
forms I wanted to duplicate. I would then write the code to
create a .FRM file based on the specific requirements (whether
from a txt file, or from filling out fields in a wizard.) This can be
done, but is so specific to the way you want to do it, that I can't
imagine a generic solution that would be any easier to use than
the VB IDE.

Good Luck :)

blabore
01-31-2002, 11:20 AM
Wow, I never realized I could open up forms using a text editor, I assumed they were saved as some nasty binary file. Thanks for the help.

kinar
02-24-2002, 06:52 PM
I am trying to do a very similar thing and am wondering how to do it.

I am also putting a fronend onto a database and wish to creat user defined forms....

i am creating an administration section to manage the database and wish to create new forms to manage new tables in the database.

I believe i know how to manipulate the form to look as i want it to but i cannot figure out how to actually create the form.....

any ideas?

Squirm
02-25-2002, 02:28 AM
If you want to create forms and controls at runtime you'd better be familiar with the Windows API first. Click here (http://64.23.12.52//Tutorials/GeneralVB/GM_Win32.asp) for a tutorial and example code.

Not for the faint-hearted. :eek:

The IceMan
02-25-2002, 11:12 PM
User Created Forms is very cool...

but it's more interesting when you create a "template" in IDE and make the changes of the forms limited to pictures and texts !

=D

clarson
02-25-2003, 01:21 PM
Creating the controls at run-time can be used to create a "form" at runtime. Create the form "template" and add the controls that users should be able to edit/modify/design through the database, and use code similar to this for each control.


Do While Not rs.EOF
' if this is a long or memory-intensive process, add DoEvents to allow for screen repaint
DoEvents
ctl_index = Control.UBound +1 ' increment index by 1

Load Control(ctl_index)

With Control(ctl_index)
.Caption = rs("item")
.Enabled = True
.Visible = True
.Value = False
' these are arbitrary values that suited my code, but display the final result in a list on the form
.Height = 255
' get the top position of the previous control, and use that reference to determine the top position of the current control you are adding
.Top = (Control(ctl_index - 1).Top + 300)
.Width = 5415
.Left = 720
End With

rs.MoveNext
Loop


This is a solution I used, and allows me to avoid re-coding forms for a program based on a database configuration. As new options are added, the form dynamically updates.

Hope this helps

Squirm
02-25-2003, 04:54 PM
This thread is a year old!
Please do not drag up such old fossils in future.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum