Link to home
Start Free TrialLog in
Avatar of walstadm
walstadm

asked on

Opening image files in VB6

I'm trying to write a program that will, at a click of a command button, open an image file in Imaging (Windows standard accessory).
SOLUTION
Avatar of D_M_D
D_M_D

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of walstadm
walstadm

ASKER

I'm getting a file not found error when I add in the file name (and I know that the file is there and correct).
try getting the program to certify the file exists befo u try to open it. an easy way to do this would be to use the open file dialog box.  (this would also eliminate tha possibility of an incorrectly spelt file path)

or have u already tried this?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah, forgot the space...

That should do it.  

You can add a Common Dialog Control to your form and let the
user select the image like suma_ds said.

Add the Microsoft Common Dialog Control to the toolbox by right clicking on the tool box and choose components...  Then choose it from the list.  Add the control to your form along with a textbox and button.  The button code is below.

' Get image path
Private Sub Command1_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub

' Then just pass the Text1.Text value as the parameter.

pathtoprogram = "C:\Program Files\Windows NT\Accessories\ImageVue\wangimg.exe "
imagetoopen = Trim(Text1.Text)
Shell pathtoprogram & imagetoopen, vbMaximizedFocus

--------
D_M_D