Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Enums

It would be great if anyone help me in converting the following vb.NET coding to VB6. I like to know how to get the value and text of a particular enum in VB6.
Thanks.

1.

Private Enum Importants
Low = 0
Normal = 1
High = 2
End Enum

Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each i As Integer In [Enum].GetValues(GetType(Importants))
MsgBox(i)
Next
End Sub


I'm writing automation scripts for activeX control.
Suppose: MyOCXCtrl.ocx.
WriterType enum and Writer Property are included in MyOCXCtrl.ocx.

Public Enum WriterType
StringWriter
ObjectWriter
BinaryWriter
End Enum

Private mWriter As WriterType

Public Property Get Writer() As WriterType
Writer = mWriter
End Property

Public Property Let Writer(vType As WriterType)
mWriter = vType
End Property

In my scripts, I like to writer as same as the following one.

TestScript.frm from other standard exe project.

Public Sub CheckingWriterProperty()
Dim ow as New MyOCX
Dim e
For Each e In [Enum].GetValues(GetType(WriterType))
ow.Writer = e
Msgbox ow.Writer
Next
End Sub

I don't want to write each enum's value manually because it might be wrong if another value is added into enum..

Public Enum WriterType
StringWriter
ObjectWriter
BinaryWriter
AnotherWriter
End Enum


Any Idea would be appreciated.
[1662 byte] By [Sync] at [2007-11-11 8:18:43]
# 1 Re: Enums
> I like to know how to get the value and text of a particular enum in VB6.

I believe you've asked this question here before, and I've believed we've told you that it's not possible to do so in VB6. It's still not. ;-)
Phil Weber at 2007-11-11 21:47:48 >
# 2 Re: Enums
Oki.. Thanks. :-)
Sync at 2007-11-11 21:48:46 >