Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Sub parameter passing

Is this the proper way to pass a varible parameter to and back from
subroutines?
My code seems a little sloppy, I would think that I'm missing some
delclaration

The subroutine "Orig_WS_name" is call with the following statement:
Call Sub Orig_WS_name("orig_name")

Private Sub Orig_WS_name(WSIn As String)
'WSIn has the value of "orig_name") prior to call
Call Add_WSname_Chars(WSIn)
'WSIn has the value of "orig_name-textadded") after call
End Sub

Private Sub Add_WSname_Chars(WS_name As String)
WS_name = WS_name & "-txt added"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Sub parameter passing

If you want to pass the changed value back up, declare the argument Byref
(the default). If youy want it passed back in its original state, declare it
Byval.


Call Orig_WS_name("orig_name")

Private Sub Orig_WS_name(ByVal WSIn As String)
MsgBox WSIn
Call Add_WSname_Chars(WSIn)
MsgBox WSIn
End Sub

Private Sub Add_WSname_Chars(ByRef WS_name As String)
WS_name = WS_name & "-txt added"
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"miek" wrote in message
...
Is this the proper way to pass a varible parameter to and back from
subroutines?
My code seems a little sloppy, I would think that I'm missing some
delclaration

The subroutine "Orig_WS_name" is call with the following statement:
Call Sub Orig_WS_name("orig_name")

Private Sub Orig_WS_name(WSIn As String)
'WSIn has the value of "orig_name") prior to call
Call Add_WSname_Chars(WSIn)
'WSIn has the value of "orig_name-textadded") after call
End Sub

Private Sub Add_WSname_Chars(WS_name As String)
WS_name = WS_name & "-txt added"
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Sub parameter passing

Thanks for your help, it is much apprecated

"Bob Phillips" wrote:

If you want to pass the changed value back up, declare the argument Byref
(the default). If youy want it passed back in its original state, declare it
Byval.


Call Orig_WS_name("orig_name")

Private Sub Orig_WS_name(ByVal WSIn As String)
MsgBox WSIn
Call Add_WSname_Chars(WSIn)
MsgBox WSIn
End Sub

Private Sub Add_WSname_Chars(ByRef WS_name As String)
WS_name = WS_name & "-txt added"
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"miek" wrote in message
...
Is this the proper way to pass a varible parameter to and back from
subroutines?
My code seems a little sloppy, I would think that I'm missing some
delclaration

The subroutine "Orig_WS_name" is call with the following statement:
Call Sub Orig_WS_name("orig_name")

Private Sub Orig_WS_name(WSIn As String)
'WSIn has the value of "orig_name") prior to call
Call Add_WSname_Chars(WSIn)
'WSIn has the value of "orig_name-textadded") after call
End Sub

Private Sub Add_WSname_Chars(WS_name As String)
WS_name = WS_name & "-txt added"
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a function as a parameter Scott Excel Programming 4 March 19th 07 11:54 PM
Passing chartobject as a parameter to sub David Cohen Excel Programming 0 September 21st 05 09:58 PM
?Passing argument/parameter just starting[_2_] Excel Programming 0 October 23rd 04 07:56 PM
?Passing argument/parameter just starting Excel Programming 1 October 23rd 04 04:23 PM
Passing a parameter to Excel keepitcool Excel Programming 3 August 13th 03 03:57 AM


All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"