473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Really stupid N00b question

When you use a function like I see posted here often, like:

Public Function Whatever()
stuff...
End Function

What do you actually do with that to make it run? I assumed you put it in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

Maybe someone can show me where to start reading on using funcitons? I start
looking through the help files but quickly get overwhelmed. Seems like
almost all subjects start past the point of square 1, like you're already
supposed to know a bunch of things before help topics even get going.

May 1 '06 #1
7 1600
You can type Whatever() in the inmediate window (CTR+G) to see what it
does, or run it in any procedure in your project, again just by typing
its name

May 1 '06 #2
There are various ways to make your public functions run;
From the Immediate window to make the example functionrun, type the following and press enter;

?whatever

To get it to run from an event, within the VBA window of the
form/report you could put the following in the chosen event;

Call Whatever

The function is run when the event is fired.

I'm sure there are others who can explain this more elegantly and
expand on your question.

Hope this helps though.

Cheers

Phil

Alan wrote: When you use a function like I see posted here often, like:

Public Function Whatever()
stuff...
End Function

What do you actually do with that to make it run? I assumed you put it in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

Maybe someone can show me where to start reading on using funcitons? I start
looking through the help files but quickly get overwhelmed. Seems like
almost all subjects start past the point of square 1, like you're already
supposed to know a bunch of things before help topics even get going.


May 1 '06 #3
Hi, Alan.
What do you actually do with that to make it run? I assumed you put it in
a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.
If it's a function or subroutine that doesn't accept any parameters, then
you can test it by placing your curson on the first line of the procedure:

Public Function Whatever() As String

.. . . and then hit the Run button (or hit <F5> or use the Run -> Run
Sub/UserForm menu), to run the procedure. If the procedure accepts
parameters, then you'll have to call this procedure from another. For
example:

Public Sub testingWhatever()
Dim myVariable As String
myVariable = "today"
MsgBox Whatever(myVariable)
End Sub

.. . . and just place the cursor on the first line of testingWhatever() and
then hit Run to find out what "today" brings you.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"Alan" <Al********@msn.com> wrote in message
news:97*******************@216.196.97.136... When you use a function like I see posted here often, like:

Public Function Whatever()
stuff...
End Function

What do you actually do with that to make it run? I assumed you put it in
a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

Maybe someone can show me where to start reading on using funcitons? I
start
looking through the help files but quickly get overwhelmed. Seems like
almost all subjects start past the point of square 1, like you're already
supposed to know a bunch of things before help topics even get going.

May 1 '06 #4
"Alan" <Al********@msn.com> wrote in message
news:97*******************@216.196.97.136...

What do you actually do with that to make it run? I assumed you put it in
a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

If the cursor is not within a procedure, VBA does not know what procedure to
run, so it gives you the popup to select from.

John... Visio MVP
May 2 '06 #5
Hi, John.

Even if the cursor is within a procedure when the Run button is hit, the
popup asking for a macro name can still show up. It happens with class
modules and with procedures that require parameters.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stonehenge.ca> wrote in message
news:35********************@magma.ca...
"Alan" <Al********@msn.com> wrote in message
news:97*******************@216.196.97.136...

What do you actually do with that to make it run? I assumed you put it
in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

If the cursor is not within a procedure, VBA does not know what procedure
to run, so it gives you the popup to select from.

John... Visio MVP

May 2 '06 #6
True. I was trying to explain why the popup was there without going into too
much details on the exceptions. The cursor can be within a procedure that
does not have parameters, but if the window does not have focus, VBA will
give the popup.

John... Visio MVP
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote in
message news:w-******************************@adelphia.com...
Hi, John.

Even if the cursor is within a procedure when the Run button is hit, the
popup asking for a macro name can still show up. It happens with class
modules and with procedures that require parameters.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stonehenge.ca> wrote in message
news:35********************@magma.ca...
"Alan" <Al********@msn.com> wrote in message
news:97*******************@216.196.97.136...

What do you actually do with that to make it run? I assumed you put it
in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

If the cursor is not within a procedure, VBA does not know what procedure
to run, so it gives you the popup to select from.

John... Visio MVP


May 2 '06 #7
Hi, John.

I learn something new every day. Thanks for testing that. It would never
occur to me to run a procedure from the VB Editor during testing that I
wasn't currently looking at.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stonehenge.ca> wrote in message
news:3r******************************@magma.ca...
True. I was trying to explain why the popup was there without going into
too much details on the exceptions. The cursor can be within a procedure
that does not have parameters, but if the window does not have focus, VBA
will give the popup.

John... Visio MVP
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AM> wrote
in message news:w-******************************@adelphia.com...
Hi, John.

Even if the cursor is within a procedure when the Run button is hit, the
popup asking for a macro name can still show up. It happens with class
modules and with procedures that require parameters.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stonehenge.ca> wrote in message
news:35********************@magma.ca...
"Alan" <Al********@msn.com> wrote in message
news:97*******************@216.196.97.136...

What do you actually do with that to make it run? I assumed you put it
in a
module. If I do that and hit the run sub/user form button I get a
popup
asking me for a Macro Name. I'm not sure what to do from here.
If the cursor is not within a procedure, VBA does not know what
procedure to run, so it gives you the popup to select from.

John... Visio MVP

May 2 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
I'd like to overwrite just one line of a binary file, based on a position set by seek(). Is there no way to do this? As far as I can tell I need to read the whole file, change the line, and write...
3
by: Anupam Kapoor | last post by:
hi all, a python n00b, so please bear with me. i have a simple question: i generally name python sources as a-simple-python-example.py. when i try to import a module named as above, i...
1
by: newgenre | last post by:
I am using a pre-built package of code for my site, which is called EasyDisc. All it does is it creates an interactive forum on your site, like any forum you see anywhere. I am having a problem...
4
by: onefry | last post by:
Hey I have this prog that i'm working on, starting my first c++ class and kind of a n00b to programming here it is #include <iostream> #include <cstdlib> using namespace std;
6
by: Charles | last post by:
I am learning from the Accelerated C++ book. The following example doesn't work and I don't know why: #include <iostream> #include <string> int main () { const std::string exclam = "!"; const...
56
by: tasteless | last post by:
Hi guys, I need really hard questions (about 10) about PHP programming (some of elements OOP as well, but no MySQL questions - this is different part), this questions needs to be very hard, but...
3
by: rtlshred | last post by:
Hello I have just, just started C++ programing. the complier I am using is Dev C++ Here is my question: Once I have written some code, How do I run the program and see the output?
2
by: benwah1983 | last post by:
Greetings, Here is my problem: The following code shows a div with two small nested divs (images with a title), then the div is closed. Another one opens and a "random text" is displayed. <div...
9
by: Alec | last post by:
Sorry guys, stupid question.... Am no programming expert and have only just started using php for creating dynamic news pages. Then I see a dynamic website without the php extension. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.