command line

You mean when you start your app so it automatically opens a text file or you open your form from another one and want to pass in the text from the text file?
 
I guess you want to open it from another form then.
Edit the constructor of your form to accept a string variable that will hold the path of the file:
Visual Basic:
Public Sub New(ByVal path As String) accept a string variable
MyBase.New()
InitializeComponent()
Dim reader As New IO.Streamreader(path)
TextBox1 = reader.ReadToEnd 'read to something, like a textbox
End Sub
You didnt really answer my last question so Im not sure what you want :).
 
Last edited:
clarification

I have over a 1000 possible forms.
Info for check boxes for each is in a text file.
I want to load a text file ,execute , load another text file etc.
Each text file contains one line of text for each checkbox.
Also want to call text files by name from the form.
May not be possible.
Thanks.
 
So for example you have a form called "Form1" and you want to open a file that has the same name, read it, create a checkbox for every line?
 
more info

I have created a form that generates checkboxes on the "fly"
I wan tto call a text file that has captions for the checkboxes and corresponding text output. Each line of the text file has info for a checkbox.
I want an automatic way to select text files by names to fill in the info for the form.

Think of it as a 1000 questtion mutiple choice test.
Sorry this is so difficult to explain.
 
Oh :), I hope I understood your question right now.

So you want to create controls when the form loads then I assume you open that form from another one which asks to select a quiz. You would have to edit the constructor of the form that displays the quiz and pass in the path to the quiz.
Visual Basic:
Dim path As string 'a variable that will keep the path
Public Sub New(ByVal quizpath as string)
MyBase.New()
InitializeComponent()
path = quizpath
End Sub
And then in your constructor or form load this:
Visual Basic:
Dim reader As New IO.StreamReader(path) 'get the path of the quiz
Dim x as Integer = 0 'keep track of how many checkboxes there is
Do While reader.Read()
checkboxes(x) = New CheckBox
checkboxes(x).Caption = reader.ReadLine() 'read the line
checkboxes(x).Location = New Point(coordinates) 
Me.Controls.Add(checkboxes(x))
x +=1
Loop
[edit]
Forgot the x += 1 line :)
[/edit]
 
Last edited:
Just make sure you use a naming convension for your files. Doing so would allow you to easily create a generic function to open whatever file you wanted (using a loop, from the constructor, whatever).

Although.. why have 100s of files when you could just use a single XML file and group questions accordingly? Then you could just write simple searching algorithms to find what you're looking for, or better yet load the XML file into memory (maybe an array, or ArrayList if need be).
 
Back
Top