-
I can't fix my InitDir when i try to load from the Open Dialog...
Hi Guys,
I suppose we are able to fix the initial directory where the Open Dialog will start when we try to load a doc.
However, for my application I cant seem to fix it. This is what happens:
When i clicked on the Load command button, the Open dialog opens up. Lets say my .InitDir = "C:\Saved Bad Images" and so the Open dialog starts from this particular "C" Drive and "Saved Bad Images" folder.
After which I decided to load a file from another directory say "C:\Saved Good Images" and it manages to load it successfully.
The problem comes:
When i try to load another doc again by clicking the same Load command button, instead of starting from the .InitDir = "C:\Saved Bad Images", it starts from the last folder ("C:\Saved Good Images") where I have just successfully loaded my last doc. Why is this happening? is it because of my coding? or is it that i have to clear any buffer or whatsoever so that this does not happen?
Guys, please help me with this...thanks a million in advance
Regards,
Justin
-
if you always have
.InitDir = "C:\Saved Bad Images"
before .ShowOpen in the Load button Click event, it should work fine... can you post the button Click code?
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
The following are the fragments of my program codes. Think it shld be sufficient. Hope you can help me out with this mstraf. Thanks a million bro...
Option Explicit
Const ErrCancel = 32755
Private Sub cmdLoadGB_Click()
If txtCurrentStatus.Text = "Paused" Then
LoadGoldenBoard
ctlImageDevice1.ActiveScene = ctlImageDevice1.DisplayScene
ctlImageDevice1.LoadImage dlgCommonDialog1.FileName
Exit Sub
End If
End Sub
Private Sub LoadGoldenBoard()
On Error Resume Next
With dlgCommonDialog1
.DialogTitle = "Open"
.InitDir = "C:\Saved GoldenBoard Images\"
.Filter = _
"Bitmap Files (*.bmp)|*.bmp|IR Images 8 Bits (*.img)|*.img|IR Images 16 Bits (*.img)|*.img|" & _
"All Images (*.bmp;*.img)|*.bmp;*.img|All Files (*.*)|*.*"
.ShowOpen
End With
If Err.Number = ErrCancel Then
Exit Sub
ElseIf Err.Number <> 0 Then
MsgBox "Error " & Format$(Err.Number) & _
" selecting file." & vbCrLf & _
Err.Description
Exit Sub
End If
On Error GoTo 0
End Sub
-
Just reset the Filename property before setting InitDir:
.FileName = ""
.InitDir = ...
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
alrite mstraf.....it works!!!....thanks alot dude....
btw is there any way u can help me out with my the other thread titled "How to convert a grayscale image to a pseudo colored image?" I have posted for quite a while now and no one seems to reply...
thanks a million in advance bro...
-
 Originally Posted by ootnitsuj
Const ErrCancel = 32755
You don't need to set a Const for pressing the Cancel button. There is already one in VB.
cdlCancel
Exit Sub
ErrHandler:
If Err <> cdlCancel Then
MsgBox Err.Description
End If
I've been programming with VB for 15 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
Martin2k
-
Another nit picky item.
If Err <> cdlCancel Then
Should be:
IF Err.Number <> cdlCancel Then
Using default properties in VB Classic can get you in trouble.
-
 Originally Posted by Keithuk
You don't need to set a Const for pressing the Cancel button. There is already one in VB.
cdlCancel
Exit Sub
ErrHandler:
If Err <> cdlCancel Then
MsgBox Err.Description
End If
Thanks for the advice bro...yah i have noticed it after i have posted these codes...thanks again...
Similar Threads
-
By Y2D in forum VB Classic
Replies: 5
Last Post: 01-03-2006, 05:52 AM
-
By MilOs in forum VB Classic
Replies: 0
Last Post: 01-24-2001, 09:55 AM
-
By MilOs in forum VB Classic
Replies: 0
Last Post: 01-24-2001, 09:55 AM
-
By MilOs in forum VB Classic
Replies: 10
Last Post: 01-23-2001, 07:52 AM
-
By MilOs in forum VB Classic
Replies: 0
Last Post: 01-19-2001, 04:25 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|