Solved

Opening image files in VB6

Posted on 2003-11-26
5
1,615 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

948 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now