I am a totally new in programming with visual basic 6. I must made a program and I have a question. In my program in main form I have a button to save a file with the data that the user has entered. When the save button pushed /clicked a new form shows and guide the user to find where the file must be saved. But when I try to do that the rest of the code for the saving is executed and the files always goes to the root directory app.path.
How I could stop the code to run and continue after the user has selects the path which the file must be saved?
Thanks in advance for your time.
May be I am not so clear. I have the main from (let’s called form1). In that form the user put some data into the form. When finishing there are two buttons the save and the exit. When the save button have been clicked a new from shows. In that new from the user select the path of where the file must be saved. After the path the from2 where the path has been chosen the program must continue with the gathering the information from the form 1 made some conversion and finally close the file. The problem is that when the user chooses the path the program has already finish with the saving of the file and as path always takes the app.path.
I give you the code of the procedure.
Dim stream As Integer
Dim basic(6), reject(6), rejectnum(6), span(6) As Double
Dim rejection(6), filepath As String
Text1.Tag = Text1.Text ‘save the text1.text because here returns the path
frmfile.Show vbModal ‘ the form which take the path
filepath = Text1.Text ‘start the code which must stopped until the data from the previous form must return. That code executes and I have the file always at app.path path always.
just a question
is the textbox(Text1.Text ) contains the complete path where it needs to be saved. or else by default it will be saved in the root application directory
if you want to save in a predefined directory please change your code as follows
filepath = filepath + ".dat"
strDir = app.Path & "\Output\"
filepath = strDir + filepath
Open filepath For Output As #stream
if your program saves before you enter the path. BY RIGHT the calling routin will wait till the modal form is closed if you are facing problem with that
why dont you just assign the path and the make the rest in a function. And call the save function later after a validation that validates the file path you want
I have another problem. When i use the modal forms and i made the executable code it seems not closing. I do not knwo why but it looks to left almost all form opens. I suppose that when the form made modal none of the rest of command about closing have effect on that. I do not know why. I post the code for everyone which have some time to take a look for a beginner which need depsertly help. I include and the executable and i like your opinions. Thank in advance for your time.