473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Get values from .exe programm in "stdout"

Hi,

Please help me as I am a newbie in VB, pretty much in all programming.
I searched many forums before, but do not know exactly what keywords to
use. I hope my question makes sense.

I have the following Sub, which calls an .exe program.

Code:
Private Sub cmdCalc_Click()
On Error GoTo Err_cmdCalc_Click

Dim stAppName As String
Dim stArgument As String

stAppName = "C:\Program Files\prog.exe"
stArgument = " " & Me.cboAge& " " & Me.cboSex
Call Shell(stAppName & stArgument, 1)

Exit_Calc_Click:
Exit Sub

Err_cmdCalc_Click:
MsgBox Err.Description
Resume Exit_cmdCalc_Click

End Sub
Now what I need, is for the value which is returned by the .exe program
to be captured by Visual Basic. I normally run this program in the
command prompt, with the arguments, and when pressing Enter, the answer
is displayed on the following line in the command prompt.

Does this involve reading the stream "stdout". If yes, how do I do it
in Access VB?

Regards,
J

Nov 13 '05 #1
3 5790
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There's probably another way to do this, but, what I do is redirect the
output of the called program to a text file. Then use VBA to read the
file. So your code would look like this:

stAppName = "C:\Program Files\prog.exe"
stArgument = " " & Me.cboAge& " " & Me.cboSex & _
" >> c:\filename.txt"
Call Shell(stAppName & stArgument, 1)

Sometimes the called program takes a while to complete. In that case
you have to wait before getting the results from the text file. There
are Shell Wait variations of the Shell function. See this site

http://www.mvps.org/access/api/api0004.htm

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQkMHQoechKqOuFEgEQKcPgCeNqSy/llP2sviQyii+vDQus/UmccAoOju
nnIDfM59XJ95H7DBjkrghm6J
=R9XJ
-----END PGP SIGNATURE-----
Jean wrote:
Hi,

Please help me as I am a newbie in VB, pretty much in all programming.
I searched many forums before, but do not know exactly what keywords to
use. I hope my question makes sense.

I have the following Sub, which calls an .exe program.

Code:
Private Sub cmdCalc_Click()
On Error GoTo Err_cmdCalc_Click

Dim stAppName As String
Dim stArgument As String

stAppName = "C:\Program Files\prog.exe"
stArgument = " " & Me.cboAge& " " & Me.cboSex
Call Shell(stAppName & stArgument, 1)

Exit_Calc_Click:
Exit Sub

Err_cmdCalc_Click:
MsgBox Err.Description
Resume Exit_cmdCalc_Click

End Sub
Now what I need, is for the value which is returned by the .exe program
to be captured by Visual Basic. I normally run this program in the
command prompt, with the arguments, and when pressing Enter, the answer
is displayed on the following line in the command prompt.

Does this involve reading the stream "stdout". If yes, how do I do it
in Access VB?

Nov 13 '05 #2
Thanks for the reply

I have tried this, but it does not work!

Strange thing is, when I copy the "Pathname" variable of the Shell
function (i.e. C:\Progra~1\Prog.exe 29 Male >> c:\temp\File1.txt ) and
paste it in the command prompt, the Text file is created! Only when
doing this through Access, it doesn't. Am I missing something here?

Here is the faulty line in Access VBA:

Code:
Call Shell("C:\Progra~1\Prog.exe 29 Male >> c:\temp\File1.txt", 1)

Thanks in advance!

Nov 13 '05 #3
I got another way of using this now, by doing the following, and it
works!

Shell Environ("comspec") & " /c " & [path to program and arguments
etc.]

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: vegetax | last post by:
How can i use cgi'like print statement in a multitreaded web framework? each thread has its own Servlet instance with request/response objects, sys.stdout = self.response(which is a file like...
25
by: Nitin Bhardwaj | last post by:
Well, i'm a relatively new into C( strictly speaking : well i'm a student and have been doing & studying C programming for the last 4 years).....and also a regular reader of "comp.lang.c" I...
8
by: jchludzinski | last post by:
Is there a format specification for printf that will result in: 1000000 being printed as 1,000,000? Or 1000000.0 as 1,000,000.0? ---John
1
by: asdsd sir | last post by:
Hi!I'm new in Python and i'd like to ask some general questions about stdin,stdout... Firstly... if we type like something like : cat "file.txt"|python somefile.py #somefile.py import sys
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
13
by: Vincent Delporte | last post by:
Hi I'm a Python newbie, and would like to rewrite this Perl scrip to be run with the Asterisk PBX: http://www.voip-info.org/wiki/view/Asterisk+NetCID Anyone knows if those lines are...
6
by: openopt | last post by:
Thank you in advance for your response. Dmitrey
11
by: Victor Lagerkvist | last post by:
Greetings, I know it's usually a bad habit to include several questions in a single message, but they are quite related. I have declared and defined a function named readin, whose purpose is to...
0
by: Gabriel Genellina | last post by:
En Thu, 25 Sep 2008 09:49:31 -0300, Almar Klein <almar.klein@gmail.com> escribió: Use subprocess.PIPE Usually the tricky part is to figure out exactly whether there is more input or not. With...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.