+ Reply to Thread
Results 1 to 8 of 8

VBA Equivalent of ASP 'Execute' Command

  1. #1
    The Vision Thing
    Guest

    VBA Equivalent of ASP 'Execute' Command

    Is there a VBA equivalent of ASP's 'Execute' command. I'd like to use such
    a command to dynamically declare variables at run-time.

    Here's a sample of ASP 'Execute' code.

    ---------------------------
    varID = fp_rs("ID")
    varName = fp_rs("Name")
    varOccupation = fp_rs("Occupation")

    for i = 1 to numFields
    Execute("var" & arr_fieldnames(i) & " = fp_rs(""" & arr_fieldnames(i) &
    """)"
    next

    ---------------------------

    Thanks,
    Wayne C.



  2. #2
    Fredrik Wahlgren
    Guest

    Re: VBA Equivalent of ASP 'Execute' Command


    "The Vision Thing" <[email protected]> wrote in message
    news:[email protected]...
    > Is there a VBA equivalent of ASP's 'Execute' command. I'd like to use

    such
    > a command to dynamically declare variables at run-time.
    >
    > Here's a sample of ASP 'Execute' code.
    >
    > ---------------------------
    > varID = fp_rs("ID")
    > varName = fp_rs("Name")
    > varOccupation = fp_rs("Occupation")
    >
    > for i = 1 to numFields
    > Execute("var" & arr_fieldnames(i) & " = fp_rs(""" & arr_fieldnames(i) &
    > """)"
    > next
    >
    > ---------------------------
    >
    > Thanks,
    > Wayne C.
    >
    >


    I think Application.Evaluate is what you are looking for.

    /Fredrik



  3. #3
    The Vision Thing
    Guest

    Re: VBA Equivalent of ASP 'Execute' Command


    "Fredrik Wahlgren" <[email protected]> wrote in message
    news:[email protected]...
    >
    > "The Vision Thing" <[email protected]> wrote in message
    > news:[email protected]...
    >> Is there a VBA equivalent of ASP's 'Execute' command. I'd like to use

    > such
    >> a command to dynamically declare variables at run-time.
    >>
    >> Here's a sample of ASP 'Execute' code.
    >>
    >> ---------------------------
    >> varID = fp_rs("ID")
    >> varName = fp_rs("Name")
    >> varOccupation = fp_rs("Occupation")
    >>
    >> for i = 1 to numFields
    >> Execute("var" & arr_fieldnames(i) & " = fp_rs(""" & arr_fieldnames(i) &
    >> """)"
    >> next
    >>
    >> ---------------------------
    >>
    >> Thanks,
    >> Wayne C.
    >>
    >>

    >
    > I think Application.Evaluate is what you are looking for.
    >
    > /Fredrik
    >
    >


    I don't think Application.Evaluate solves the problem. I want to
    dynamically declare variables and assign values like so:-

    For i = 1 to Ubound(arrIn)
    Dim ("var" & i) as string
    ("var" & i) = arrIn(i)
    Next

    Regards,
    Wayne C.



  4. #4
    Dave Peterson
    Guest

    Re: VBA Equivalent of ASP 'Execute' Command

    Are you executing a different program?

    Take a look at Shell in VBA's help.

    Are you running a different subroutine?

    Application.Run

    maybe it.

    The Vision Thing wrote:
    >
    > Is there a VBA equivalent of ASP's 'Execute' command. I'd like to use such
    > a command to dynamically declare variables at run-time.
    >
    > Here's a sample of ASP 'Execute' code.
    >
    > ---------------------------
    > varID = fp_rs("ID")
    > varName = fp_rs("Name")
    > varOccupation = fp_rs("Occupation")
    >
    > for i = 1 to numFields
    > Execute("var" & arr_fieldnames(i) & " = fp_rs(""" & arr_fieldnames(i) &
    > """)"
    > next
    >
    > ---------------------------
    >
    > Thanks,
    > Wayne C.


    --

    Dave Peterson

  5. #5
    The Vision Thing
    Guest

    Re: VBA Equivalent of ASP 'Execute' Command


    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Are you executing a different program?
    >
    > Take a look at Shell in VBA's help.
    >
    > Are you running a different subroutine?
    >
    > Application.Run
    >
    > maybe it.
    >
    > The Vision Thing wrote:
    >>
    >> Is there a VBA equivalent of ASP's 'Execute' command. I'd like to use
    >> such
    >> a command to dynamically declare variables at run-time.
    >>
    >> Here's a sample of ASP 'Execute' code.
    >>
    >> ---------------------------
    >> varID = fp_rs("ID")
    >> varName = fp_rs("Name")
    >> varOccupation = fp_rs("Occupation")
    >>
    >> for i = 1 to numFields
    >> Execute("var" & arr_fieldnames(i) & " = fp_rs(""" & arr_fieldnames(i) &
    >> """)"
    >> next
    >>
    >> ---------------------------
    >>
    >> Thanks,
    >> Wayne C.

    >
    > --
    >
    > Dave Peterson


    What I'm trying to do is dynamically declare variables and assign values to
    them, like so

    For i = 1 to Ubound(arrIn)
    Dim ("var" & arrIn(i)) as string
    ("var" & arrIn(i)) = arrIn(i)
    Next

    Regards,
    Wayne C.



  6. #6
    Dave Peterson
    Guest

    Re: VBA Equivalent of ASP 'Execute' Command

    VBA doesn't support that kind of symbolic substitution.

    The Vision Thing wrote:
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    > > Are you executing a different program?
    > >
    > > Take a look at Shell in VBA's help.
    > >
    > > Are you running a different subroutine?
    > >
    > > Application.Run
    > >
    > > maybe it.
    > >
    > > The Vision Thing wrote:
    > >>
    > >> Is there a VBA equivalent of ASP's 'Execute' command. I'd like to use
    > >> such
    > >> a command to dynamically declare variables at run-time.
    > >>
    > >> Here's a sample of ASP 'Execute' code.
    > >>
    > >> ---------------------------
    > >> varID = fp_rs("ID")
    > >> varName = fp_rs("Name")
    > >> varOccupation = fp_rs("Occupation")
    > >>
    > >> for i = 1 to numFields
    > >> Execute("var" & arr_fieldnames(i) & " = fp_rs(""" & arr_fieldnames(i) &
    > >> """)"
    > >> next
    > >>
    > >> ---------------------------
    > >>
    > >> Thanks,
    > >> Wayne C.

    > >
    > > --
    > >
    > > Dave Peterson

    >
    > What I'm trying to do is dynamically declare variables and assign values to
    > them, like so
    >
    > For i = 1 to Ubound(arrIn)
    > Dim ("var" & arrIn(i)) as string
    > ("var" & arrIn(i)) = arrIn(i)
    > Next
    >
    > Regards,
    > Wayne C.


    --

    Dave Peterson

  7. #7
    The Vision Thing
    Guest

    Re: VBA Equivalent of ASP 'Execute' Command

    Thanks Dave, that's what I needed to know.

    Wayne C.

    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > VBA doesn't support that kind of symbolic substitution.
    >
    > The Vision Thing wrote:
    >>
    >> "Dave Peterson" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > Are you executing a different program?
    >> >
    >> > Take a look at Shell in VBA's help.
    >> >
    >> > Are you running a different subroutine?
    >> >
    >> > Application.Run
    >> >
    >> > maybe it.
    >> >
    >> > The Vision Thing wrote:
    >> >>
    >> >> Is there a VBA equivalent of ASP's 'Execute' command. I'd like to use
    >> >> such
    >> >> a command to dynamically declare variables at run-time.
    >> >>
    >> >> Here's a sample of ASP 'Execute' code.
    >> >>
    >> >> ---------------------------
    >> >> varID = fp_rs("ID")
    >> >> varName = fp_rs("Name")
    >> >> varOccupation = fp_rs("Occupation")
    >> >>
    >> >> for i = 1 to numFields
    >> >> Execute("var" & arr_fieldnames(i) & " = fp_rs(""" &
    >> >> arr_fieldnames(i) &
    >> >> """)"
    >> >> next
    >> >>
    >> >> ---------------------------
    >> >>
    >> >> Thanks,
    >> >> Wayne C.
    >> >
    >> > --
    >> >
    >> > Dave Peterson

    >>
    >> What I'm trying to do is dynamically declare variables and assign values
    >> to
    >> them, like so
    >>
    >> For i = 1 to Ubound(arrIn)
    >> Dim ("var" & arrIn(i)) as string
    >> ("var" & arrIn(i)) = arrIn(i)
    >> Next
    >>
    >> Regards,
    >> Wayne C.

    >
    > --
    >
    > Dave Peterson




  8. #8
    Tim Williams
    Guest

    Re: VBA Equivalent of ASP 'Execute' Command

    I'm not sure there aren't better ways to achieve this - declaring
    variables on the fly is not really good practise. You would be much
    better off using a dictionary object or array for what you're trying
    to do.


    Tim.


    "The Vision Thing" <[email protected]> wrote in message
    news:%[email protected]...
    > Thanks Dave, that's what I needed to know.
    >
    > Wayne C.
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    >> VBA doesn't support that kind of symbolic substitution.
    >>
    >> The Vision Thing wrote:
    >>>
    >>> "Dave Peterson" <[email protected]> wrote in message
    >>> news:[email protected]...
    >>> > Are you executing a different program?
    >>> >
    >>> > Take a look at Shell in VBA's help.
    >>> >
    >>> > Are you running a different subroutine?
    >>> >
    >>> > Application.Run
    >>> >
    >>> > maybe it.
    >>> >
    >>> > The Vision Thing wrote:
    >>> >>
    >>> >> Is there a VBA equivalent of ASP's 'Execute' command. I'd like
    >>> >> to use
    >>> >> such
    >>> >> a command to dynamically declare variables at run-time.
    >>> >>
    >>> >> Here's a sample of ASP 'Execute' code.
    >>> >>
    >>> >> ---------------------------
    >>> >> varID = fp_rs("ID")
    >>> >> varName = fp_rs("Name")
    >>> >> varOccupation = fp_rs("Occupation")
    >>> >>
    >>> >> for i = 1 to numFields
    >>> >> Execute("var" & arr_fieldnames(i) & " = fp_rs(""" &
    >>> >> arr_fieldnames(i) &
    >>> >> """)"
    >>> >> next
    >>> >>
    >>> >> ---------------------------
    >>> >>
    >>> >> Thanks,
    >>> >> Wayne C.
    >>> >
    >>> > --
    >>> >
    >>> > Dave Peterson
    >>>
    >>> What I'm trying to do is dynamically declare variables and assign
    >>> values to
    >>> them, like so
    >>>
    >>> For i = 1 to Ubound(arrIn)
    >>> Dim ("var" & arrIn(i)) as string
    >>> ("var" & arrIn(i)) = arrIn(i)
    >>> Next
    >>>
    >>> Regards,
    >>> Wayne C.

    >>
    >> --
    >>
    >> Dave Peterson

    >
    >




+ 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