473,395 Members | 1,458 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,395 software developers and data experts.

Do I need the "Public" in the following... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean

MLH
The following function declaration confuses me...

Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef
sReason As String) As Boolean

I tried pasting it and its code into an Access 2.0 module. I was
unsuccessful. I had to remove the following...
"Public"
"Optional ByRef"
"As Boolean"

I replaced the "As Boolean" with "As Integer". Then it all worked.
What's the "Public" and "Optional ByRef" for anyway?
Nov 13 '05 #1
4 2633
MLH wrote:
The following function declaration confuses me...

Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef
sReason As String) As Boolean

I tried pasting it and its code into an Access 2.0 module. I was
unsuccessful. I had to remove the following...
"Public"
"Optional ByRef"
"As Boolean"

I replaced the "As Boolean" with "As Integer". Then it all worked.
What's the "Public" and "Optional ByRef" for anyway?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Public" means the function is "visible" to all possible calling
routines (the Public is allowed to use it).

"Optinal ByRef" means the parameter is an optional parameter (it may, or
may not be used by the calling routine) and that instead of the actual
parameter value there is a pointer to the value. A pointer is an
address in the computer's memory that "points" to the variable value
(or, sometimes, another pointer - don't worry about it). The converse
to ByRef is ByVal which means the actual parameter value has been passed
to the function/sub.

"As Boolean" means the value returned by the Function will be a Boolean
(True/False - in VBA True = -1; False = 0) value.

I believe all these terms were introduced into Access VBA in
Access/Office 97 - not sure. That's why they don't work in Access 2.
Ya really have to upgrade to a newer version :-).

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQijUToechKqOuFEgEQK5SACgwixwE11OdugS8vjTob10VW nT/UcAn0lj
AObQXErYVkkXy2cJRHL6Abg3
=5kl6
-----END PGP SIGNATURE-----
Nov 13 '05 #2
"MGFoster" <me@privacy.com> wrote in message
news:fv***************@newsread3.news.pas.earthlin k.net...
MLH wrote:
The following function declaration confuses me...

Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef
sReason As String) As Boolean

I tried pasting it and its code into an Access 2.0 module. I was
unsuccessful. I had to remove the following...
"Public"
"Optional ByRef"
"As Boolean"

I replaced the "As Boolean" with "As Integer". Then it all worked.
What's the "Public" and "Optional ByRef" for anyway?


"Public" means the function is "visible" to all possible calling
routines (the Public is allowed to use it).

"Optinal ByRef" means the parameter is an optional parameter (it may, or
may not be used by the calling routine) and that instead of the actual
parameter value there is a pointer to the value. A pointer is an
address in the computer's memory that "points" to the variable value
(or, sometimes, another pointer - don't worry about it). The converse
to ByRef is ByVal which means the actual parameter value has been passed
to the function/sub.

"As Boolean" means the value returned by the Function will be a Boolean
(True/False - in VBA True = -1; False = 0) value.

I believe all these terms were introduced into Access VBA in
Access/Office 97 - not sure. That's why they don't work in Access 2.
Ya really have to upgrade to a newer version :-).


Even in Access 97, I don't believe you can declare Optional and As String
unless you define a default value: you have to use As Variant.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

Nov 13 '05 #3
Douglas J. Steele wrote:

Even in Access 97, I don't believe you can declare Optional and As String
unless you define a default value: you have to use As Variant.


IIRC you only needed "As Variant" if you wanted to check for IsMissing()
otherwise the default value of a string ("") or number (0) will be
passed. Can't quite remember if "optional" was in 97 or not, long time
since I used it.

--
This sig left intentionally blank
Nov 13 '05 #4
"Trevor Best" <no****@besty.org.uk> wrote in message
news:42**********************@news.zen.co.uk...
Douglas J. Steele wrote:

Even in Access 97, I don't believe you can declare Optional and As String
unless you define a default value: you have to use As Variant.


IIRC you only needed "As Variant" if you wanted to check for IsMissing()
otherwise the default value of a string ("") or number (0) will be passed.
Can't quite remember if "optional" was in 97 or not, long time since I
used it.


You convinced me to go test it, and right you are. In fact, if you declare
the parameter As Variant, you must use IsMissing with it. If it is missing,
you'll get an error if you try to refer to it.

Yes, Optional is available in 97

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


Nov 13 '05 #5

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

Similar topics

3
by: Maurice Walmsley | last post by:
I'll avoid tell you how lame I am and get straight to the question... I need a good expanation to the "ByVal sender As Object, ByVal e As System.EventArgs" part of; Public Sub...
23
by: Rogers | last post by:
I want to compare strings of numbers that have a circular boundary condition. This means that the string is arranged in a loop without an end-of-string. The comparaison of two strings now...
5
by: Ian Rutherford | last post by:
Heya guys, It seems VB .net no longer supports the awesome ability of VB 6 to declare something as a string and specify how long the string would be all in one line: Public myString as String *...
0
by: Benjamin Lukner | last post by:
Hi! I'd like to dynamically call API functions from different DLLs, depending on what platform the program runs. Now I'm wondering what the most simple way may be (without meta code and compiler...
7
by: ReidarT | last post by:
I have this line of code Public Navn1 As String = "Per" I want to change it to another 'text' by entering some text in a textbox like navn1 = 'Nils' and then the line should look like
1
by: beniro | last post by:
Hello, all. I'm implementing LinkPoint API on my site, but I have an error coming up in their code, and I'm wondering if anyone could give me any guidance on this one. Here is the specific error:...
6
by: .rhavin grobert | last post by:
hello;-) i frequently need the following construction: ReturnParam § Function() § { /...do something.../ someType var § = something; /...do something.../ return something;
3
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I'm getting this error message when running a LINQtoSQL query. My entity classes are as follows: public partial class Activity { #region Fields public DateTime Activity_Date { get; set; }
5
by: peter1234 | last post by:
Could you please confirm if 'Public Type', as defined below, is possible with Access 2003. Symilar example found in a book for Access 2007. Public Type TypeName Type as String Temp as Single ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.