Drive List Errors!

I have the following code.  The reason I'm posting this is when I run the program and try to open a file on the root of C with VB6 the PC locks and requires a reboot.  Any help making it so I can get a file from the Root of a drive would be appreciated.


Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
    On Error GoTo DriveHandler
    Dir1.Path = Drive1.Drive
    Exit Sub
   
DriveHandler:
    Drive1.Drive = Dir1.Path
    Exit Sub
End Sub

Private Sub File1_Click()
    SelectedFile = File1.Path & "\" & File1.FileName
    Image1.Picture = LoadPicture(SelectedFile)
LVL 2
pete_perryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
In the File1_Click Sub... Instead of:

   SelectedFile = File1.Path & "\" & File1.FileName

Try this:

   SelectedFile = File1.Path
   If Not Right$(SelectedFile,1) = "\" then SelectedFile = SelectedFile + "\"
   SelectedFile = SelectedFile + File1.FileName



Cheers!
0
pete_perryAuthor Commented:
Ok, just one quick question?  Are those 3 seperate lines?
0
idoreyCommented:
SelectedFile = File1.Path is one line and the rest is all on the same line.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

pete_perryAuthor Commented:
Ok, just one quick question?  Are those 3 seperate lines?
0
pete_perryAuthor Commented:
Sorry, that last one was an accident!  However, the locking stopped but now it won't open any images.
0
pete_perryAuthor Commented:
Sorry, that last one was an accident!  However, the locking stopped but now it won't open any images.
0
mcriderCommented:
What kind of image are you loading?
0
mcriderCommented:
idorey, wrong...

The code I gave is 3 separate lines...

Line 1:

 SelectedFile = File1.Path

Line2 :

 If Not Right$(SelectedFile,1) = "\" then SelectedFile = SelectedFile + "\"

Line 3:

 SelectedFile = SelectedFile + File1.FileName



Cheers!

0
pete_perryAuthor Commented:
Just a bmp, or gif or something.  I'm just trying to learn this and all 4 of the books I have don't tell you how to get around this error.
0
pete_perryAuthor Commented:
Sorry, I had to review my actions as I accidently deleted the load image statement.  I'm an idiot sometimes.  Ok, one last thing how do I set the default drive to C:\ it's stuck at D:\ because that's where the vb is installed!  I upped it to 75 because of my stupidity!
0
pete_perryAuthor Commented:
Oh yeah, McRider it did work by the way!
Thanks!
0
pete_perryAuthor Commented:
Oh yeah, McRider it did work by the way!
Thanks!
0
mcriderCommented:
You can use the following to change the drive:

   ChDrive "C"

Once the drive is set, you can use the following to change the directory:

   ChDir "C:\whatever_path_you_want"


Glad I could help... (Hoping for a good grade)


Cheers!      
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pete_perryAuthor Commented:
You got it!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.