Re: How to provide a list of value when passing a paramater...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 08/10/04


Date: Tue, 10 Aug 2004 00:51:38 -0400

define an enum, and declare a variable of that type, eg ...

Private Enum RegisterHotKeyModifiers
   MOD_ALT = &H1
   MOD_CONTROL = &H2
   MOD_SHIFT = &H4
End Enum

Private Sub Command1_Click()

   Dim reg As RegisterHotKeyModifiers

   reg= <get intellisense listing>

End Sub

.. or in a procedure, to get intellisense when writing the call ...

private function whatever(reg As RegisterHotKeyModifiers) as long
   'code
end function

...

   x = whatever(<get intellisense listing>)

Enums can start at any value, and in the absence of a defined value the next
value is +1 over the last ...

private enum transporttypes
    boats = 1
    cars
    trains
    planes
end enum

cars = 2, trains 3 etc. Or you can assign random values ...

private enum transporttypes
    boats = 1
    cars = 74
    trains = 44
    planes = 67
end enum

If you want to use words separated by a space, use square brackets

Private Enum transporttypes
    boats = 1
    cars = 74
    [electric trains] = 44
    planes = 67
End Enum

If you want to hide a value from intellisense, but still be able to use it
(most useful if you're defining classes that expose enums and you want to
reserve some members that won't show when defined), preface the enum
constant with an underscore and enclose in square brackets ...

Private Enum transporttypes
    boats = 1
    cars = 74
    [electric trains] = 44
    planes = 67
    [_mopeds] = -1
End Enum

You can still reference mopeds, but it won't show in the list ...

  Dim tr As transporttypes
   tr = [_mopeds]
   Print tr

If you look in the Object Browser (F2) under Project1 you'll see
transporttypes listed, but the [_mopeds] is not shown. If you right-click
the window and select "show hidden members" you'll see _mopeds.

-- 
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"K.K." <someone@microsoft.com> wrote in message 
news:eBaDQBpfEHA.3556@TK2MSFTNGP12.phx.gbl...
: Hi all,
:
: I have a function that  will accept a string as parameter, but I just want
: it to accept few defined values, like the property of text box when we 
type
: Text1"dot", it shows a list of value... can anyone tell me how to do that?
:
: K.K.
:
: 


Relevant Pages

  • Losing Module Level ENums in Excel 2003
    ... regular module. ... DisplayName = 3& ... Private Enum ePropertyIndex ...
    (microsoft.public.excel.programming)
  • RE: Losing Module Level ENums in Excel 2003
    ... Compile under the Debug Menu, ... DisplayName = 3& ... Private Enum ePropertyIndex ...
    (microsoft.public.excel.programming)
  • Re: return a private enum
    ... I may need a set/get but I don't know how to do that on an enum. ... public class SomeClass ... private enum Status; ... return NOK; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: nested enum
    ... For example, private enum inside0 ... public enum inside0 implements outside ...
    (comp.lang.java.help)