Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
mb mb is offline
external usenet poster
 
Posts: 10
Default Pass a variable back to the host script?

How do I pass the end result of a subroutine back to the host script? In
the example below I would like the next_week to come back to the
Pull_Forward.

Public Sub Pull_Forward()

num = InputBox("Enter the range (in calendar days) you wish to include
in the Pull Forward Calculation: ")
Call Module1.current_date(num)
Call Module1.Pull_Fwd


End Sub

Private Sub current_date(num)
today = Date
today = Format(today, "mm/dd")
next_week = DateAdd("d", num, today)
next_week = Format(next_week, "mm/dd")
MsgBox (next_week)
End Sub

Thanks,
mb


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Pass a variable back to the host script?

Instead os a sub you are better off with a function. Functions return values
where as subs perform actions. Sum is a function. It returns the sum of the
input numbers. So your function will look like this...

Public Sub Pull_Forward()
dim strWeek as string
num = InputBox("Enter the range (in calendar days) you wish to include
in the Pull Forward Calculation: ")
strWeek = Module1.current_date(num)
Call Module1.Pull_Fwd
End Sub

Private Function current_date(byval num as integer) as string
today = Date
today = Format(today, "mm/dd")
next_week = DateAdd("d", num, today)
next_week = Format(next_week, "mm/dd")
current_date = next_week
End Sub


--
HTH...

Jim Thomlinson


"mb" wrote:

How do I pass the end result of a subroutine back to the host script? In
the example below I would like the next_week to come back to the
Pull_Forward.

Public Sub Pull_Forward()

num = InputBox("Enter the range (in calendar days) you wish to include
in the Pull Forward Calculation: ")
Call Module1.current_date(num)
Call Module1.Pull_Fwd


End Sub

Private Sub current_date(num)
today = Date
today = Format(today, "mm/dd")
next_week = DateAdd("d", num, today)
next_week = Format(next_week, "mm/dd")
MsgBox (next_week)
End Sub

Thanks,
mb



  #3   Report Post  
Posted to microsoft.public.excel.programming
mb mb is offline
external usenet poster
 
Posts: 10
Default Pass a variable back to the host script? (Resolved)

thanks.

"Jim Thomlinson" wrote in message
...
Instead os a sub you are better off with a function. Functions return

values
where as subs perform actions. Sum is a function. It returns the sum of

the
input numbers. So your function will look like this...

Public Sub Pull_Forward()
dim strWeek as string
num = InputBox("Enter the range (in calendar days) you wish to include
in the Pull Forward Calculation: ")
strWeek = Module1.current_date(num)
Call Module1.Pull_Fwd
End Sub

Private Function current_date(byval num as integer) as string
today = Date
today = Format(today, "mm/dd")
next_week = DateAdd("d", num, today)
next_week = Format(next_week, "mm/dd")
current_date = next_week
End Sub


--
HTH...

Jim Thomlinson


"mb" wrote:

How do I pass the end result of a subroutine back to the host script?

In
the example below I would like the next_week to come back to the
Pull_Forward.

Public Sub Pull_Forward()

num = InputBox("Enter the range (in calendar days) you wish to

include
in the Pull Forward Calculation: ")
Call Module1.current_date(num)
Call Module1.Pull_Fwd


End Sub

Private Sub current_date(num)
today = Date
today = Format(today, "mm/dd")
next_week = DateAdd("d", num, today)
next_week = Format(next_week, "mm/dd")
MsgBox (next_week)
End Sub

Thanks,
mb





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
Pass control back to Excel window [email protected] Excel Worksheet Functions 1 December 29th 06 07:24 PM
How to pass a variable into an SQL statement CLamar Excel Discussion (Misc queries) 0 June 5th 06 02:17 PM
How to pass a variable from Form back to calling procedure John[_111_] Excel Programming 4 August 21st 05 03:54 PM
Using Public to Pass Variable D.Parker Excel Programming 8 March 24th 05 10:39 PM
How to pass variable value between macros BCS Excel Programming 0 July 25th 03 08:01 PM


All times are GMT +1. The time now is 04:29 AM.

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"