Results 1 to 13 of 13

Thread: (Resolved) Ideas on quicker way to create forms with many fields

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Resolved (Resolved) Ideas on quicker way to create forms with many fields

    Hello all,
    Wondering if anyone has ideas on how to generate code for controls for forms with many fields.
    These are for applications where the VB form needs to simulate an existing paper form with, say 50 fields on it; let's say they are checkbox items.
    As you know, it is a tedious process to create this in the VS IDE: placing each checkbox on the form and entering the desired text for it as well as renaming it.
    It would be nice if there was some kind of utility that could (say) take an Excel spreadsheet in with (say) two columns: CheckboxName and CheckboxText, and generate all or part of the code to create a VB form containing those checkboxes.
    Any ideas?
    Last edited by BruceG; Sep 4th, 2021 at 12:52 AM. Reason: Resolved
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Ideas on quicker way to create forms with many fields

    I don't know of an utility. If I had to create a multi button form I would use an int loop adding + 1 to the name and getting the size and position of the previous inserted control so I can place the current on the form. As you say this might be excel, it makes it easier to add the name and text as you already got them, put the excel columns to a list or dictionary or something similar and do a for each. The most challenging would be the position of the controls, if they reach the end of the form, if they start stacking to the right etc....
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Ideas on quicker way to create forms with many fields

    Hi sapator, thanks for your response. I know this type of thing can be done at run-time by dynamically adding controls as you suggest. What I am looking for here is a "design time" solution - something that would generate code for the FormX.Designer.vb file, so once that file is updated, I could further manipulate the controls on the form etc. The "excel" or input file could have additional parameters for location (i.e. top and left).

    Now that I am looking at a Designer.vb file from one of my projects, I suppose it would not be too difficult to write a stand-alone program that would read in an Excel (csv) file with the parameters I described, and generate code for the Designer.vb file to a text file, and from that text file copy and paste it into the real Designer.vb file in my project ...
    "It's cold gin time again ..."

    Check out my website here.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Ideas on quicker way to create forms with many fields

    Quote Originally Posted by BruceG View Post
    Now that I am looking at a Designer.vb file from one of my projects, I suppose it would not be too difficult to write a stand-alone program that would read in an Excel (csv) file with the parameters I described, and generate code for the Designer.vb file to a text file, and from that text file copy and paste it into the real Designer.vb file in my project ...
    That’s what I was about to suggest…

  5. #5

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Ideas on quicker way to create forms with many fields

    Great minds ...
    "It's cold gin time again ..."

    Check out my website here.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Ideas on quicker way to create forms with many fields

    Quote Originally Posted by BruceG View Post
    Great minds ...
    ...and fools never differ.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Ideas on quicker way to create forms with many fields

    Quote Originally Posted by jmcilhinney View Post
    ...and fools never differ.
    Oh??? How would you attack this problem?

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Ideas on quicker way to create forms with many fields

    Quote Originally Posted by BruceG View Post
    Great minds ...
    The only thing I would do differently is that I’d create the entire Designer.vb file. No copying and pasting. Just change the name and put it in place of the original file

  9. #9

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Ideas on quicker way to create forms with many fields

    Thanks .paul. - no need for nastiness here - job trying to get work done.
    "It's cold gin time again ..."

    Check out my website here.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Ideas on quicker way to create forms with many fields

    Quote Originally Posted by .paul. View Post
    Oh??? How would you attack this problem?
    That wasn't a criticism of anything you've done here. It was just a joke (hence the wink) based on the full expression, as I've heard it: "great minds think alike and fools never differ".
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: (Resolved) Ideas on quicker way to create forms with many fields

    No offense taken then.
    I have marked this as resolved, as I was able to write a quick utility to do what has been described (read in a csv file with the desired control types, names, text, etc.) and output the equivalent code that can be pasted into a designer.vb file. Not pretty or turn-key, but it works and will save tons of time for these types of customer requests ("hey, can you automate this form?" - a 1-page Word document, small font single-spaced with 100 items on it ...)
    "It's cold gin time again ..."

    Check out my website here.

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: (Resolved) Ideas on quicker way to create forms with many fields

    You could probably make the process smoother by building it into a VS extension. It's a matter of whether it's worth the investment in time and effort to create that to save a bit of time on each occasion you want to perform this task.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  13. #13
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: (Resolved) Ideas on quicker way to create forms with many fields

    Quote Originally Posted by jmcilhinney View Post
    You could probably make the process smoother by building it into a VS extension. It's a matter of whether it's worth the investment in time and effort to create that to save a bit of time on each occasion you want to perform this task.
    That's a further step i could've suggested. I'd think it would be quite an improvement to create an entire Designer.vb file, or at least edit the existing one without resorting to copying and pasting manually.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width