+ Reply to Thread
Results 1 to 3 of 3

Pass a variable back to the host script?

  1. #1
    mb
    Guest

    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. #2
    Jim Thomlinson
    Guest

    RE: 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. #3
    mb
    Guest

    Re: Pass a variable back to the host script? (Resolved)

    thanks.

    "Jim Thomlinson" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1