dbTalk Databases Forums  

Class or Function that lists options

comp.databases.ms-access comp.databases.ms-access


Discuss Class or Function that lists options in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Penguin
 
Posts: n/a

Default Class or Function that lists options - 12-13-2004 , 10:51 PM






We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?


' ------ Class clsSunRiseSet
' Version 2.01
Option Explicit
Public frm As Form
' -- The following properties are exposed:
'Sunrise (r) - Sunrise time
'Sunset (r) - Sunset time
'SolarNoon (r) - Solar noon
'
'CityCount (r) - Number of cities
'CityName (r) - Name of city, by index
'City (w) - Sets the longitude/latitude/timezone based off a city
' name or city index
'TimeZone (r/w) - Current Timezone
'DaySavings (r/w) - Daylight savings time in effect
'Longitude (r/w) - Longitude to calculate for
'Latitude (r/w) - Latitude to calculate for
''DateDay (r/w) - Date to calculate for
''
' -- The following method is exposed
'CalculateSun - Calculate sunrise, sunset and solar noon
'
' Scott Seligman
' http://www.scottandmichelle.net/scott/
' Based off of
' http://www.srrb.noaa.gov/highlights/sunrise/gen.html


Reply With Quote
  #2  
Old   
Steve Jorgensen
 
Posts: n/a

Default Re: Class or Function that lists options - 12-13-2004 , 11:56 PM






I believe what you are looking for is Enum. Read up on the Enum.

On 13 Dec 2004 20:51:59 -0800, "Penguin" <rhondastein (AT) yahoo (DOT) com> wrote:

Quote:
We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?


' ------ Class clsSunRiseSet
' Version 2.01
Option Explicit
Public frm As Form
' -- The following properties are exposed:
'Sunrise (r) - Sunrise time
'Sunset (r) - Sunset time
'SolarNoon (r) - Solar noon
'
'CityCount (r) - Number of cities
'CityName (r) - Name of city, by index
'City (w) - Sets the longitude/latitude/timezone based off a city
' name or city index
'TimeZone (r/w) - Current Timezone
'DaySavings (r/w) - Daylight savings time in effect
'Longitude (r/w) - Longitude to calculate for
'Latitude (r/w) - Latitude to calculate for
''DateDay (r/w) - Date to calculate for
''
' -- The following method is exposed
'CalculateSun - Calculate sunrise, sunset and solar noon
'
' Scott Seligman
' http://www.scottandmichelle.net/scott/
' Based off of
' http://www.srrb.noaa.gov/highlights/sunrise/gen.html


Reply With Quote
  #3  
Old   
Allen Browne
 
Posts: n/a

Default Re: Class or Function that lists options - 12-14-2004 , 12:00 AM



You are asking for an enumeration:

Enum MyList
dog = 1
cat = 2
End Enum
Public Function TestMyList(MyMember As MyList)
Debug.Print MyMember
End Function

BTW, you can also use the built-in enumerations, e.g.:
Dim Response As VbMsgBoxResult

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Penguin" <rhondastein (AT) yahoo (DOT) com> wrote

Quote:
We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?


' ------ Class clsSunRiseSet
' Version 2.01
Option Explicit
Public frm As Form
' -- The following properties are exposed:
'Sunrise (r) - Sunrise time
'Sunset (r) - Sunset time
'SolarNoon (r) - Solar noon
'
'CityCount (r) - Number of cities
'CityName (r) - Name of city, by index
'City (w) - Sets the longitude/latitude/timezone based off a city
' name or city index
'TimeZone (r/w) - Current Timezone
'DaySavings (r/w) - Daylight savings time in effect
'Longitude (r/w) - Longitude to calculate for
'Latitude (r/w) - Latitude to calculate for
''DateDay (r/w) - Date to calculate for
''
' -- The following method is exposed
'CalculateSun - Calculate sunrise, sunset and solar noon
'
' Scott Seligman
' http://www.scottandmichelle.net/scott/
' Based off of
' http://www.srrb.noaa.gov/highlights/sunrise/gen.html



Reply With Quote
  #4  
Old   
Penguin
 
Posts: n/a

Default Re: Class or Function that lists options - 12-16-2004 , 10:18 PM



Thanks for your responses. Unfortunately, enum is not available in
Access 97. From various searches it would appear that one can declare
constants, but how can you get them to show up in intellisense?

I also tried to look at dim abc as combobox or as dropdown - but there
didn't seem to be much info. Would this help me?


Reply With Quote
  #5  
Old   
Steve Jorgensen
 
Posts: n/a

Default Re: Class or Function that lists options - 12-17-2004 , 01:21 AM



On 16 Dec 2004 20:18:46 -0800, "Penguin" <rhondastein (AT) yahoo (DOT) com> wrote:

Quote:
Thanks for your responses. Unfortunately, enum is not available in
Access 97. From various searches it would appear that one can declare
constants, but how can you get them to show up in intellisense?

I also tried to look at dim abc as combobox or as dropdown - but there
didn't seem to be much info. Would this help me?
You didn't say it was Access 97. I don't think yuo can do it without making
an ActiveX library on VB6.


Reply With Quote
  #6  
Old   
Bas Cost Budde
 
Posts: n/a

Default Re: Class or Function that lists options - 12-17-2004 , 02:00 AM



Penguin wrote:
Quote:
We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?
No, there is no enum in A97.

I did this by creating public methods for every constant. It is not the
same as intellisense, as you still have to type the class name (using
the generic reference)

CalculateSunrise.city = clsSunRiseSet.

and a list of methods including the constants follows. You could even
have a separate class (possibly with a shorter name) containing just
those constants, exposed as methods.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea


Reply With Quote
  #7  
Old   
Penguin
 
Posts: n/a

Default Re: Class or Function that lists options - 12-17-2004 , 09:51 AM



All I have is VB4 (and no help on it either!) I assume since you
mention VB6 that I can't do it in VB4?


Reply With Quote
  #8  
Old   
Steve Jorgensen
 
Posts: n/a

Default Re: Class or Function that lists options - 12-17-2004 , 10:01 AM



On 17 Dec 2004 07:51:08 -0800, "Penguin" <rhondastein (AT) yahoo (DOT) com> wrote:

Quote:
All I have is VB4 (and no help on it either!) I assume since you
mention VB6 that I can't do it in VB4?
That is correct. I think it might be possible in VB5, but I'm not certain.


Reply With Quote
  #9  
Old   
Allen Browne
 
Posts: n/a

Default Re: Class or Function that lists options - 12-18-2004 , 07:52 AM



I don't have VB4 to test, but Enum may have been introduced after that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Penguin" <rhondastein (AT) yahoo (DOT) com> wrote

Quote:
All I have is VB4 (and no help on it either!) I assume since you
mention VB6 that I can't do it in VB4?



Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.