PC Review


Reply
Thread Tools Rate Thread

Function and Immediate window

 
 
Wavequation
Guest
Posts: n/a
 
      16th Sep 2009
This is a stupid question, but I am writing and testing a function.
Shouldn't I be able to type the function name, include any values, and
pressing enter, have the result printed in the immediate window?
as a simple example

function Test(strTest as string) as string
test = strTest
end function

Then typing:
Test("Test String")
in the immediate window should yield:
Test String
Directely below it
 
Reply With Quote
 
 
 
 
Jack Leach
Guest
Posts: n/a
 
      16th Sep 2009
It should... if the Function is in Public Scope

Often I declare as Public for testing and go back to Private after the
procedure is proofed.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Wavequation" wrote:

> This is a stupid question, but I am writing and testing a function.
> Shouldn't I be able to type the function name, include any values, and
> pressing enter, have the result printed in the immediate window?
> as a simple example
>
> function Test(strTest as string) as string
> test = strTest
> end function
>
> Then typing:
> Test("Test String")
> in the immediate window should yield:
> Test String
> Directely below it

 
Reply With Quote
 
 
 
 
Jack Leach
Guest
Posts: n/a
 
      16th Sep 2009
Whoops!


You need to include ? at the beginning of the line to say you want the
return printed:

?Test("Test String")
Test String

just plain old Test with no ? will run the function but not return the value


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Jack Leach" wrote:

> It should... if the Function is in Public Scope
>
> Often I declare as Public for testing and go back to Private after the
> procedure is proofed.
>
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "Wavequation" wrote:
>
> > This is a stupid question, but I am writing and testing a function.
> > Shouldn't I be able to type the function name, include any values, and
> > pressing enter, have the result printed in the immediate window?
> > as a simple example
> >
> > function Test(strTest as string) as string
> > test = strTest
> > end function
> >
> > Then typing:
> > Test("Test String")
> > in the immediate window should yield:
> > Test String
> > Directely below it

 
Reply With Quote
 
Banana
Guest
Posts: n/a
 
      16th Sep 2009
Off the top of my head, you may need to prefix with a ?

?Test("Test String")

in the immediate windows. You also can do this:

debug.print Test("Test String")

which is actually the same thing.

HTH.

Wavequation wrote:
> This is a stupid question, but I am writing and testing a function.
> Shouldn't I be able to type the function name, include any values, and
> pressing enter, have the result printed in the immediate window?
> as a simple example
>
> function Test(strTest as string) as string
> test = strTest
> end function
>
> Then typing:
> Test("Test String")
> in the immediate window should yield:
> Test String
> Directely below it

 
Reply With Quote
 
Wavequation
Guest
Posts: n/a
 
      16th Sep 2009
That's the part I forgot!

"Jack Leach" wrote:

> Whoops!
>
>
> You need to include ? at the beginning of the line to say you want the
> return printed:
>
> ?Test("Test String")
> Test String
>
> just plain old Test with no ? will run the function but not return the value
>
>
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "Jack Leach" wrote:
>
> > It should... if the Function is in Public Scope
> >
> > Often I declare as Public for testing and go back to Private after the
> > procedure is proofed.
> >
> > --
> > Jack Leach
> > www.tristatemachine.com
> >
> > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > -Thomas Edison (1847-1931)
> >
> >
> >
> > "Wavequation" wrote:
> >
> > > This is a stupid question, but I am writing and testing a function.
> > > Shouldn't I be able to type the function name, include any values, and
> > > pressing enter, have the result printed in the immediate window?
> > > as a simple example
> > >
> > > function Test(strTest as string) as string
> > > test = strTest
> > > end function
> > >
> > > Then typing:
> > > Test("Test String")
> > > in the immediate window should yield:
> > > Test String
> > > Directely below it

 
Reply With Quote
 
David H
Guest
Posts: n/a
 
      16th Sep 2009
I'll even add several Debug.Print statement throughout the statement, and at
the end so I can see what's going on with the function. Doing so eliminates
the need for the '?'

"Wavequation" wrote:

> This is a stupid question, but I am writing and testing a function.
> Shouldn't I be able to type the function name, include any values, and
> pressing enter, have the result printed in the immediate window?
> as a simple example
>
> function Test(strTest as string) as string
> test = strTest
> end function
>
> Then typing:
> Test("Test String")
> in the immediate window should yield:
> Test String
> Directely below it

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Watch Window disappears and not available but Immediate and Local owlnevada Microsoft Excel Programming 2 24th Jun 2008 11:39 PM
Modal Window Locking Only Immediate Parent Window CodeChamp Microsoft Dot NET Framework 1 19th May 2007 12:03 AM
VBA line of code executes in Immediate Window but not in Code Window EagleOne@discussions.microsoft.com Microsoft Excel Misc 2 30th Apr 2007 02:52 PM
Immediate Window not showing up below code window =?Utf-8?B?RXhjZWxNb25rZXk=?= Microsoft Excel Programming 1 22nd Mar 2006 01:02 AM
Results different in Output window than Immediate Window Dave Microsoft Dot NET 2 8th Oct 2003 05:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:48 AM.