473,756 Members | 2,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Cli ck

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_Cli ck:
MsgBox Err.Description
Resume Exit_cmdCalc_Cl ick

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 5810
-----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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQkMHQoechKq OuFEgEQKcPgCeNq Sy/llP2sviQyii+vDQ us/UmccAoOju
nnIDfM59XJ95H7D Bjkrghm6J
=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_Cli ck

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_Cli ck:
MsgBox Err.Description
Resume Exit_cmdCalc_Cl ick

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\Pro g.exe 29 Male >> c:\temp\File1.t xt ) 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:\Progr a~1\Prog.exe 29 Male >> c:\temp\File1.t xt", 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("comspe c") & " /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
1896
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 object) wont work because all threads will set the same file object and it will be a concurrence mess. I am out of ideas here,so any hacks welcome =)
25
3096
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 don't have a copy of ANSI C89 standard,therefore i had to post this question: What is the difference between "unspecified" behaviour & "undefined" behaviour of some C Code ??
8
15496
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
7475
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
6508
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" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
13
3158
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 necessary, why, and what their alternative is in Python?
6
12426
by: openopt | last post by:
Thank you in advance for your response. Dmitrey
11
1888
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 get input from stdin and save the result in a character array (provided the input does not exceed the maximum limit). Somehow it feels natural that readin will then have the type "char *" and return the obtained input to whoever calls it (or...
0
1996
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 Python it's easy, use the ps1 prompt. --- begin --- import sys
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.