Solved

Opening image files in VB6

Posted on 2003-11-26
5
1,623 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Progress

690 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