hazejean Posted July 21, 2003 Posted July 21, 2003 how do you send a command line from one form to another form? Quote
*Experts* mutant Posted July 21, 2003 *Experts* Posted July 21, 2003 You cant send command lines between forms, are trying to pass information between two forms? Quote
hazejean Posted July 21, 2003 Author Posted July 21, 2003 text files need to load an external text file into form Quote
wyrd Posted July 21, 2003 Posted July 21, 2003 You can give one form a public method that reads a file, then call it from the other form. Quote Gamer extraordinaire. Programmer wannabe.
*Experts* mutant Posted July 21, 2003 *Experts* Posted July 21, 2003 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? Quote
hazejean Posted July 21, 2003 Author Posted July 21, 2003 yes to open ... want to load text file when form opens. Quote
*Experts* mutant Posted July 21, 2003 *Experts* Posted July 21, 2003 (edited) 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: 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 :). Edited July 21, 2003 by mutant Quote
hazejean Posted July 21, 2003 Author Posted July 21, 2003 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. Quote
*Experts* mutant Posted July 21, 2003 *Experts* Posted July 21, 2003 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? Quote
hazejean Posted July 21, 2003 Author Posted July 21, 2003 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. Quote
*Experts* mutant Posted July 21, 2003 *Experts* Posted July 21, 2003 (edited) 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. 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: 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] Edited July 21, 2003 by mutant Quote
wyrd Posted July 21, 2003 Posted July 21, 2003 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). Quote Gamer extraordinaire. Programmer wannabe.
hazejean Posted July 21, 2003 Author Posted July 21, 2003 Thanks Thanks much. I think I have a direction now. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.