|
-
Jul 12th, 2000, 03:41 AM
#1
Thread Starter
Hyperactive Member
Why does this return a type mismatch error?
Code:
Enum frTags
HEADO = "<head>"
BODYO = "<body>"
HEADC = "</head>"
BODYC = "</body>"
End Enum
Can enumerated constants only be numeric?
-
Jul 12th, 2000, 03:53 AM
#2
Frenzied Member
Yes is the Short answer, you can use Constants
Const HEADO As String = "<head>"
Const BODYO As String = "<body>"
Const HEADC As String = "</head>"
Const BODYC As String = "</body>"
but Enums are numeric values only I'm afraid.
-
Jul 12th, 2000, 03:55 AM
#3
Thread Starter
Hyperactive Member
Aagh
Bang go my thoughts of autocomplete dropdowns! I may as well type the HTML!
-
Jul 12th, 2000, 04:10 AM
#4
Frenzied Member
not necceserilly You Could Have Something like this
Code:
Enum frTags
HEADO
BODYO
HEADC
BODYC
End Enum
Public Function GetTag(eTag as frTag) as String
Select Case eTag
Case HEADO
GetTag = "<head>"
Case BODYO
GetTag = "<body>"
Case HEADC
GetTag = "</head>"
Case BODYC
GetTag = "</body>"
End Select
End Function
then you can use the enum in your function calls as long as you call this function
-
Jul 12th, 2000, 04:22 AM
#5
Thread Starter
Hyperactive Member
Extra work
Thanks for the suggestion but it isn't wholly practical. I woud have to type
Code:
GetTag frTags.BODYO
-
Jul 12th, 2000, 04:31 AM
#6
Frenzied Member
the clue is in the name enum mean it has to be a number! 
you could use a class module
frTags class:
Code:
Option Explicit
Public Property Get HEADO() As String
HEADO = "<head>"
End Property
Public Property Get BODYO() As String
BODYO = "<body>"
End Property
Public Property Get HEADC() As String
HEADC = "</head>"
End Property
Public Property Get BODYC() As String
BODYC = "</body>"
End Property
and in your form...
Code:
Option Explicit
Private Sub Command1_Click()
Dim t As New frTags
doSomthing t.BODYC
End Sub
Private Sub doSomthing(tag As String)
MsgBox tag
End Sub
-
Jul 12th, 2000, 04:47 AM
#7
Frenzied Member
If you're using the Function you Don't need to Type
Code:
GetTag frTags.BODYO
just you'll still get the picklist because the function is expecting an enum, If you use the Classmodule have it as a seperate dll, then set it's instancing to 6 - GlobalMultiUse and you can use it without declaring one, If you just have
Code:
Public Const OHEAD As String = "<head>"
then It will Take Up far less memory, and have most of the advantages of the Enum. or Have the GetTag inside it as the Default Method an don't bother with the Property, than it will work almost exactly like an Enum.
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
|