NetNomad312
Technical User
Hey again. Sorry for my dumb questions, but I haven't had the option to take a course in this lately. My knowledge of VB is limited to a really basic course two years ago that tought us nothing about common dialog control, and a tutorial on common dialog control that didn't say anything about what happens when the user clicks "cancel" on such a dialog. I looked in the MSDN library, but unless I missed it, that didn't help me either.
Essentially, all I'm doing at this point is making a program that opens and saves a text-based type of file. It's basically just Notepad with a couple extra features that relate to this kind of file. I've used the Open dialog before, to select files in another program of mine (that would in turn pass them as arguments to another program - it was a frontend, really).
In this program, I managed to load a text file and have the program print it line-by-line into a textbox. But the "cancel" button never works; if it had a filename in the box, it would open that file anyway if I clicked cancel. It's the same thing with the save box. I ran it through debug... the line that's supposed to get the filename is:
result = cdlOpen.FileName
Maybe I'm just being newbish and I'm expecting too much, but I thought that if you clicked cancel, then cdlOpen.FileName would be empty, right? The checks that come after this test to see if result <> "" , and if I get a filename anyway, they're of no use. Same thing with the save dialog. I would, for instance, have my program create a file, then I would change it and try to resave it. When the dialog appeared, the filename would already be in the box. I clicked cancel, and it asked me to overwrite as if I had clicked OK. That's the other thing - my save-dialogs don't ask to overwrite, they just do it... so I programmed one in myself using a message box.
So my questions are these:
1. How do I get it to tell when I clicked "cancel" as opposed to "open" or "save?"
2. Aren't save dialogs supposed to figure out whether a file exists and ask to overwrite it? If not, how do I program one in the correct way (as mine will appear after the dialog is closed)?
Thanks again... you guys really are helpful. :-/
Essentially, all I'm doing at this point is making a program that opens and saves a text-based type of file. It's basically just Notepad with a couple extra features that relate to this kind of file. I've used the Open dialog before, to select files in another program of mine (that would in turn pass them as arguments to another program - it was a frontend, really).
In this program, I managed to load a text file and have the program print it line-by-line into a textbox. But the "cancel" button never works; if it had a filename in the box, it would open that file anyway if I clicked cancel. It's the same thing with the save box. I ran it through debug... the line that's supposed to get the filename is:
result = cdlOpen.FileName
Maybe I'm just being newbish and I'm expecting too much, but I thought that if you clicked cancel, then cdlOpen.FileName would be empty, right? The checks that come after this test to see if result <> "" , and if I get a filename anyway, they're of no use. Same thing with the save dialog. I would, for instance, have my program create a file, then I would change it and try to resave it. When the dialog appeared, the filename would already be in the box. I clicked cancel, and it asked me to overwrite as if I had clicked OK. That's the other thing - my save-dialogs don't ask to overwrite, they just do it... so I programmed one in myself using a message box.
So my questions are these:
1. How do I get it to tell when I clicked "cancel" as opposed to "open" or "save?"
2. Aren't save dialogs supposed to figure out whether a file exists and ask to overwrite it? If not, how do I program one in the correct way (as mine will appear after the dialog is closed)?
Thanks again... you guys really are helpful. :-/