Passing Arguements


What i am looking to do, and i am not sure how i go about doin it.
I am working with someone else in a project, and he is doin one side and i am doin the other. What is going to happen, is that he is going to pass me a value (integer value), and now i have to capture this value and carry on with my criteria.
Now how do i set up an arguement as such?
Where an integer value is passed and i capture it?

Hope you understand what i need

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you going to be writing just a function that he passes a value to?

Are you writing a seperate .EXE that will be passed a variable?

MYEEXE.EXE VariableToUse

In your Program look at Command Method of VB.
When you say pass you a value do you mean from one exe to another or is it in the same code like into a function?
Is it all within a single VB project?

If so then he makes a .bas module with a public variable in it which you can both access.  Or you can make a function where he passes you the value as an argument by calling it.

public function interface(iArg as integer) as integer

'receives an integer and passes back an integer'

end function

'perhpas need an overview of what you are doing

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mscalaAuthor Commented:
Yes, i am writing a seperate exe, that will be passed a variable.
when you run your exe you can send it parameters like

shell "MyApp.exe hello test"

this would be interpretated by the activated exe using the command method.

strArgs = Command()
in this example strArgs would equal "hello test"
myApp.exe of course should be a full path to your app
If you call one .exe from the other then use

dim sCall as string
dim yourInt as integer

sCall = "second.exe " & cstr(YourInt)

shell sCall


then in the second .exe use

dim iIntVal as integer

iIntVal = cint(command$)

If both are running concurrently and you want to swap values, then you can write to a simple file in one app then poll it in the other, but check for file errors e.g locking.
Of course this only passes info on start up of the app if you want to pass data to an already running app there are various methods some easier than others.
Passing paramters you could also use simple registry instead of files.

savesetting "Projectname","Settings","newVal",value

then poll it from the other app

i think i missed this out

You could use the 'command' system
(See VB help files)
For example, suppose you create an alarm clock application. One of the techniques for setting the alarm time is to let the user type in the selected time directly. The user might enter the following string in the Run dialog box:

Alarm 11:00:00

The Command function returns all arguments entered after the application name (in this case, Alarm). The Alarm application has only one argument, so in the application code, you can assign this argument directly to the string that stores the selected time:

AlarmTime = Command

If Command returns an empty string, there are no command-line arguments. The application must either ask for the information directly or select a default action.

Tell us more about what you and the other guy are doing. What kind of project is it? How often does the value get passed? Is it just once or is it passed many times? Are the two programs running at the same time? Are you fimilar with DDE?
Tell us more about what you are doing. Your program always is call with the other guy .exe?
mscalaAuthor Commented:
This a part of the code i am using, but illistrates what i need.

Dim SQLDB As New ADODB.Connection
Dim EliteDB As New ADODB.Connection

Dim RsWriteHeader As New ADODB.Recordset
Dim SqlWriteHeader As String

SQLDB.Open "Provider=SQLOLEDB.1;Persist Security Info=False;" _
   & "User ID=" & "Michael" & ";Password=" & "Michael" & ";" _
   & "Initial Catalog=BDBMaster;Data Source=SqlServer"
EliteDB.Open "Provider=MSDASQL.1;Persist Security Info=False;" _
 & "User ID=Michael;Data Source=Paradox;Initial Catalog=c:\WINELITE\DATA\LIVE"

SqlWriteHeader = "Select * from tblBDBBatchHeader where BatchNo like '2'"
RsWriteHeader.Open SqlWriteHeader, SQLDB, adOpenStatic, adLockOptimistic, adCmdText

RsWriteHeader("BatchStatus") = "C"


Basically in my sql statement, where i say :  Where BatchNo like '2', this 2 is hardcoded, and basially that number will be passed a variable.
mscalaAuthor Commented:
Didn't answer anything

SqlWriteHeader = "Select * from tblBDBBatchHeader where BatchNo like '" & Format(yourVariable,"#") & "'"

This will put yourVariable value as an integer in the SqlWriteHeader string.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.