Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Question about the Common Dialog control of VB6  (Read 367 times)
Magnum357jhp
Community Member
*
Posts: 128


« on: January 27, 2012, 02:01:29 PM »

I have a problem that I hope someone here might help me with.  I've been trying to make a program that is suppose to display a dialog box to load a sequencial .dat file but whenever I try to load click on the file through the dialog box I get a "Code 52 error" that indicates something is wrong with the file's name.  I'm at a loss on what to do because I need the program to access different named files through the dialog box, not just one set perameter name.  Here is the following code I'm using...

Code:
Private Sub mnuLoadLeague_Click()
CommonDialog1.Filter = "Data Files(*.dat)"
CommonDialog1.ShowOpen
LeagueName = CommonDialog1.FileName

Open App.Path + "..\League Data\" + LeagueName + ".dat" For Input As #1
Input #1, LeagueName, LeagueStructureSelection, PostseasonTournamentBowlGameSelection
Close #1

End Sub

The problem seems to be occuring in line 3.  It doesn't seem to want to pass on the files name to "LeagueName" to allow the dialog box to access different named files.  Am I doing something wrong here?
Logged

"There is no such thing as the ultimate programming language.  Every language has its weaknesses."
Mithrandir_
Moderator
Community Member
*****
Posts: 349


WWW
« Reply #1 on: January 27, 2012, 06:23:21 PM »

You should step through the code to see what the value of LeagueName is. Then you would notice that CommonDialog1.FileName returns you the full path + filename (eg C:\Folder\MyFile.txt). If you use CommonDialog1.FileTitle then the filename and extension are returned.

So, instead of having:

Open App.Path + "..\League Data\" + LeagueName + ".dat" For Input As #1

just do:

Open LeagueName For Input As #1
Logged

Magnum357jhp
Community Member
*
Posts: 128


« Reply #2 on: January 27, 2012, 11:14:33 PM »

Thank you for the help, that did the trick!   Smiley
Logged

"There is no such thing as the ultimate programming language.  Every language has its weaknesses."
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks