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

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Document Generator?


I'm trying to make a document generator. What I want to be able to do is have a user have 3 options from the start, Make a new document, Load a saved document, and Delete an Old Document. If the user makes a new document (the main part of the program) then a wizard pops up and walks them through it. They'd be able to write the document title in a textbox, the author, etc. All in text boxes. When the wizard is complete, it takes all the data from those text boxes and puts it into a document that can be printed/saved. Any ideas on how to implement this?

One other thing I should note. The main part of the document is structured around dates. I've already programmed this, but when a user clicks a date on a calendar, it adds the date to the data and would then put that on the document. So if the user clicks 5 dates: 2/1, 2/2, 2/3, 2/4, and 2/5; it would put the following on the document:






What I'd like to do is create forms at runtime for however many dates the user clicked, so that they can edit the "etc" data for each date. So, using the above example, if they clicked 5 dates, 5 forms would be created at runtime that had textboxes on them to edit what went under that date.

Any help would be great.
  • 2
1 Solution
It is not quite clear for me what exactly your problem is. Obviously, you have these tasks to solve:
1. Code the wizard user interface
2. Format the data as they are needed in the document
3. Write the document
Maybe you could state in which area your problem is. Or is it in all of them?

As to your specific question at the end, you need to understand that coding a form is more or less the same as coding a class, and that at runtime you create one or more instances of this class. So once you have coded the  form for editing the "etc" stuff, let us say you called the form "fEtc", at runtime you create and display as many instances of this form as you like through code like
dim f as fEtc
set f=new fEtc
show f
where f holds a pointer to an instance of the fEtc form.
VeniferxAuthor Commented:
Thanks RMatzka.

What my problem is is
1 2 and 3. I've written simple documents before, but nothing on the scale of what I want to do, with formatting and all. I'd like some pointers or maybe code examples on how to do it. Has a similar program been made that's open source so I could take a look there and learn from it?

I have most of the wizard coded already, I just need to know how to transfer the data from the textboxes to some kind of temporary file to be loaded into the document, or just loaded directly into the document. I also need to know how to format it. Should I create a template and then replace things with the data that the user put it? Or should I create it on the fly?

I guess you could say I'm just inexperienced and maybe have bitten off more than I can chew, but I need to start somewhere. Like I said, any help would be appreciated.
I Don't know about examples, but can try and give you a few hints.
1. The best way to code a wizard UI is as a wizard loop. Each time the user clicks Next or Back, another round of the loop starts. You could e.g. have an array of frames without border, all of the same size and position, and the simplest way to  control which one is visible is by calling its ZOrder method. And you have an index variable which is incremented when the user clicks "Next" and decremented when she clicks "Back", so you know which page should be shown in the next round of the loop.
2. Let me assume your document is going to be a .txt file. If it were to be a Word document, things are more complex. The easeast way to prepare the contents of a text file is to have a string array, and prepare it thus that each field in this array is meant to be one line in the file. Use ReDim Preserve if you don't know the number of lines in advance. Formatting a line is then not much more than simple string manipulation, using "&" and string manipulation functions such as "String": e.g. you use String(10," ") if you need to insert 10 blanks, or you use s=s & String(10-len(s)," ") if you need to fill up the string in s with blanks such that the whole thing fills 10 character positions. Also, for dates and other numeric data, the Format function is very useful, although it has its intricacies.
3. That's the easy part.
Dim sFile as String
Dim iFile as Integer
Dim iLineNo as Integer
Dim sLines()as String
... assume sLines() has been prepared as explained above
... assume sFile contains the path and filename to write
Open sFile For Output As iFile
For iLineNo = 0 To UBound(sLines)
 Print #iFile,sLines(iLineNo)
Next iLineNo
Close iFile
Hi Veniferx,
It appears that you have forgotten to close this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept RMatzka's comment(s) as an answer.

Veniferx, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.
DanRollins -- EE database cleanup volunteer

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now