|
-
Oct 18th, 2004, 04:07 AM
#1
Thread Starter
Evil Genius
structure/enum question
I've got a program installed here which has a form which people can fill out. One of it's drop down boxes allows you to select a value from either "default", "none" or you can enter a value from 0 to 100 in it (for a percentage).
I want to expose ths field from a class I'm writing, so when a class instance is created, this value can be set & a method called to fill this entry in the form.
What is the best / most professional way of exposing something like this which can allow multiple data types? I don't really want to expose this as a string if I can help it to minimize the chance of a wrong figure being specified.
VB Code:
Public Structure xyz
Public _default as boolean
Public none as Boolean
Public Percentage as system.web.ui.webcontrols.unit
End Structure
Public Enum xyz
_default = 0
none = 1
_1percent = 2
_2percent = 3
...
_100percent = 102
End Class
These are about the only ways I can think of, neither of which look any good! Can anyone recommend how I could do this please?
Thanks!
-
Oct 18th, 2004, 04:53 AM
#2
Retired VBF Adm1nistrator
How about just specifying it as an Integer, and use 1 or 2 special values?
e.g.
-2 = None
-1 = Default
0 = 0%
1 = 1%
2 = 2%
etc.
That would be the quickest from a performance point of view anyway..., it would also make it easier to expand upon if you developed a more complicated version of your application - i.e. Integers are serializable whereas Enums are not
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Oct 18th, 2004, 05:15 AM
#3
Thread Starter
Evil Genius
Not a bad suggestion there! Cheers Jamie, I owe you a pint for that!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|