Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 18th, 2005, 2:56 PM   #1
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
"open" dialog boxes

hello,

in a program i'm trying to write, i've got a certain part where the user clicks on a button that says "load list" and the program reads from an external text file in a hardcoded location and fills in a listbox based on the contents of that text file.

i've got the reading/writing the external text file part down, but i would like to be able to allow the user to specify what text file they would like to open in the first place by clicking on "load list" as if it were a "browse for file" button.

i know this is a very, very noob question concerning visual basic but most of my programming background comes from qbasic many years ago, and i never had to deal with forms, APIs or all that much graphical interaction back then

i did find one site that provided code that explained how to do it, but it didn't work for me (i'm using VB6, i think it was geared towards .NET) and it was too complex for me to understand how to fix it. so if someone can summarize the basics of what i need to summon an "open" dialog box, i'd appreciate it.

thanks

edit: while i'm at it,

once the user has found the file they want to load and loaded it, i've got another button labeled "edit list" for which i want to open the actual text file they specify in notepad. for the life of me i can't figure out how to actually open an external file. i've tried the shell and appactivate commands but neither seemed to work.

Last edited by chepfaust; Feb 18th, 2005 at 3:01 PM.
chepfaust is offline   Reply With Quote
Old Feb 18th, 2005, 3:14 PM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
check this out:

http://msdn.microsoft.com/library/de...ialogboxes.asp

should help.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Feb 18th, 2005, 3:20 PM   #3
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
score!

thanks much
chepfaust is offline   Reply With Quote
Old Feb 18th, 2005, 3:42 PM   #4
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
no prolem man. msdn is a great resource for vb programming.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Feb 18th, 2005, 4:04 PM   #5
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
use a cmdb
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Feb 18th, 2005, 11:23 PM   #6
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
ok cool so i got the hang of dialog boxes; it was as easy and simple as i thought it'd be.

however i still haven't figured out how to open an external file (need to open a specified notepad file at the push of a button), so if anybody has any pointers on that i'd appreciate it.

thanks
chepfaust is offline   Reply With Quote
Old Mar 8th, 2005, 8:48 PM   #7
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
new question concerning open dialog boxes-

when the user clicks on "cancel" in an "open" dialog box, is there any way to get a value from the user's action?

for example my current problem is that in the dialog box, if the user clicks on a file but clicks on "cancel," the program will continue on as if the user clicked on the file and clicked "open." how do i stop this?

thanks

edit:

actually i figured it out, i think. i've now manually set the commondialogOpen.filename to "" before initiating commondialogOpen.action = 1. i think the problem was that once i used the commondialog, the default filename carried over from the previous time i used the CDL, so my manual setting the filename to nothing would allow me to use a if cdlOpen.filename = "" statement to cancel out of the subroutine.

Last edited by chepfaust; Mar 9th, 2005 at 2:15 AM.
chepfaust is offline   Reply With Quote
Old Mar 9th, 2005, 9:45 AM   #8
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
I think that the Cancel button returns something like a 0 or something like that, i can't remember, since it's been a long time since i've done anything with VB.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Mar 9th, 2005, 11:02 AM   #9
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
Here is for Opening the file

Private sub loadlist_click()
CommonDialog.ShowOpen
Open CommonDialog1.Filename for Output As 1
Read 1
__________________
And there was much rejoicing... Yay....

Last edited by Cipher; Mar 9th, 2005 at 11:05 AM. Reason: Forgot [/code] tag
Cipher is offline   Reply With Quote
Old Mar 10th, 2005, 3:05 PM   #10
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Quote:
Originally Posted by Pizentios
I think that the Cancel button returns something like a 0 or something like that, i can't remember, since it's been a long time since i've done anything with VB.
If you set the CancelError property of the dialog control to true, a specified run time error is raised, which you can catch.
However, I'd recommend using the APIs themselver directly. They are much better, more flexible, and plus no one seems to have Comdlg in their system, meaning that unless you copy the ocx onto every computer, you'll get a fatal error.
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC