Function and Immediate window

W

Wavequation

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
 
J

Jack Leach

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)
 
J

Jack Leach

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)
 
B

Banana

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.
 
W

Wavequation

That's the part I forgot!

Jack Leach said:
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)
 
D

David H

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 '?'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top