Solved

Opening image files in VB6

Posted on 2003-11-26
5
1,619 Views
Last Modified: 2010-04-17
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).
0
Comment
Question by:walstadm
5 Comments
 
LVL 10

Assisted Solution

by:D_M_D
D_M_D earned 125 total points
ID: 9826920
Use the Shell ()

Try this example:

' open image in Imaging
Dim pathtoprogram, imagetoopen As String
pathtoprogram = "C:\Program Files\Windows NT\Accessories\ImageVue\wangimg.exe"
imagetoopen = "ImageName.bmp"
Shell pathtoprogram & imagetoopen, vbMaximizedFocus

--------
D_M_D
0
 

Author Comment

by:walstadm
ID: 9827044
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).
0
 
LVL 1

Expert Comment

by:suma_ds
ID: 9828973
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?
0
 
LVL 9

Accepted Solution

by:
bhagyesht earned 125 total points
ID: 9829536
D_M_D is code is right just add a space after the wangimg.exe
modified code is as follows
(make sure the path is correct for the imaging software on my pc (win2k) its  at "C:\Program Files\Windows NT\Accessories\ImageVue\kodakimg.exe")


' open image in Imaging
Dim pathtoprogram, imagetoopen As String
pathtoprogram = "C:\Program Files\Windows NT\Accessories\ImageVue\kodakimg.exe
imagetoopen = "ImageName.bmp"
Shell pathtoprogram & imagetoopen, vbMaximizedFocus
0
 
LVL 10

Expert Comment

by:D_M_D
ID: 9833935
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
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question