Vb.net question concerns textfile , reflesh and control forms

cheryla

New member
Joined
Oct 8, 2004
Messages
1
Programming Experience
Beginner
i hv found a few probelms recently.

1.About the text file
Having done a series of experiments, i found out that the program can read a text file with the file name provided only. However, the program can also read a file without providing path only when the files and the program are in the same directory.(quite similar to pascal) Therefore, i would like to ask whether there is a method that can "package" the program and the files together so that the player do not need proveide the path of the file for the program to read.
( P.s If this problem can be solved by "packaging", it will be very convenient!!)

2. About the form
If there are two forms called A and B. When A is run , and i click a button in A, then B will be shown.
How can i prevent players inputting things in A when B is shown ?

3. About refresh the whole program
If the player has won the game and he wants to start a new game, can i just refresh the program and show the new game instead of asking the player to quit and start the program again?
I hv thought about calling those "Private Sub" (<== are they procedures?) , However it failed to do.
I tried to call those "Private Sub" using this code:
Call Form1_Load ()
But the VB said that there should be some parameters or sth else to add. (Actaully , i dun know wut is it talking about?)
Can you tell me another method to call a procedure(or those "Private Sub")?

Please give some solutions for my problems. Thx !!!
 
Seems you have quite a bit to learn about VB.NET. I would suggest reading a bit, there are lots of great sites and books out there.

To answer your questions though,

1. If you want the text file to be seperate from the executable, you can create an installation or deployment application that will compress the executable and text file together, then when the application is installed, the seperate files will be decompressed to the same folder. Here's a link to one of the many articles concerning Deploying VB.NET apps: Deploying Applications in VB.NET: Part 1/2
Be careful when not supplying the entire path to the text file, especially if you are using OpenDialog controls as the 'working' directory can be changed. It is a good practice to always supply the entire path. Use Application.StartupPath plus the filename if the file is in the same directory as the executable.

A different approach would be to use resources to embed the text into the application.

2. Use the ShowDialog method instead of Show.

3. The best way would depend on the design. You can however close the form and open a new instance of the form.

Happy programming.
 
Back
Top