ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling sub programs (https://www.excelbanter.com/excel-programming/285568-calling-sub-programs.html)

ChuckM[_2_]

Calling sub programs
 
How do I call subprograms from other programs...and pass information back and forth.

Thanks
chuck

KM[_2_]

Calling sub programs
 
Hi,
Calling sub won't help because sub procedures only carry
out commands, functions on the other return values.

So use something like

Public Function fncStrLen(strData as string) as Long
fncStrLen = Len(strData)
End Function

put the following in your debug window and press return

fncStrLen("abcde")

rsult being 5

regards
KM

For more information double click on Function to highlight
it and press F1 for help.
-----Original Message-----
How do I call subprograms from other programs...and pass

information back and forth.

Thanks
chuck
.


Tom Ogilvy

Calling sub programs
 
You can pass information in the arguments going in both directions if they
are passed byref

Sub Sub1()
myval = 3
othersub myval, someval
msgbox myval & " - " & someval
End sub

Sub Othersub( abc, someval)
abc = abc^abc
someval = "STUV"
End Sub


--
Regards,
Tom Ogilvy


"KM" wrote in message
...
Hi,
Calling sub won't help because sub procedures only carry
out commands, functions on the other return values.

So use something like

Public Function fncStrLen(strData as string) as Long
fncStrLen = Len(strData)
End Function

put the following in your debug window and press return

fncStrLen("abcde")

rsult being 5

regards
KM

For more information double click on Function to highlight
it and press F1 for help.
-----Original Message-----
How do I call subprograms from other programs...and pass

information back and forth.

Thanks
chuck
.





All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com