Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Getting The Text Of An Excel Enum

Enum DelinquencyTier
 [30 - 59 Days]
 [60 - 89 Days]
 [90 + Days]
End Enum

How would I obtain the text value of the constants in VBA?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Enum In Enum In Enum In Type In Enum?.. Whoah
Hey folks... I don't know the possiblilty of this, but what the hell..

Is it possible to have an enum under another enum?.. or under another UDT?..

so I could for example go..


where SystemDefaults is either a toplevel enum/UDT for other default property lists..

.ServerDefaults is another enum housing;

.serv_HTTP = 80
.serv_FTP = 21

thanks in advance.. any advice much appreciated

From Text To Enum (VB6)
Hello all.

Quick question here. (VB6)
I'm programming a game in vb and writing a scripting system for it. I'm reading the scripts from an XML file. Anyway, Some of the script options are Enum, like

Enum pComparisonType
coEquals = 0
coGreaterThan = 1
coGreaterThanEqualTo = 2
coLessThan = 3
coLessThanEqualTo = 4
End Enum
and a variable within each case is

CompareType As pComparisonType
Now, I got an xml that I'm reading from. When I read the text from a node, such as 'coEquals' or '0', I can't simply say

CompareType = node.text
I cant CType it either, because the Enum isn't a recognized type. If I convert the text to an integer, like '0' into 0 then

CompareType = cint(node.text)
doesnt work either because you cant go from integer to Enum.

Finally, I must do something like

CompareType = GetpObjectRef(Node.Text)
which calls

Public Function GetpObjectRef(s As String) As pObjectRef
Select Case s
Case "orRef"
GetpObjectRef = orRef
Case "orAll"
GetpObjectRef = orAll
Case "orNone"
GetpObjectRef = orNone
Case "orAtLeastOne"
GetpObjectRef = orAtLeastOne
Case "orExactlyOne"
GetpObjectRef = orExactlyOne
Case "orEqualToRefNum"
GetpObjectRef = orEqualToRefNum
Case "orGreaterThanRefNum"
GetpObjectRef = orGreaterThanRefNum
Case "orGreaterThanEqualToRefNum"
GetpObjectRef = orGreaterThanEqualToRefNum
Case "orLessThanRefNum"
GetpObjectRef = orLessThanRefNum
Case "orLessThanEqualToRefNum"
GetpObjectRef = orLessThanEqualToRefNum
Case Else
GetpObjectRef = orRef
End Select
End Function
Ofcourse, this works, but its horribly inefficient to write. I'd have to do it for every Enum type variable I have. I could switch to ints instead of Enums, but thats ugly and very unpreferable.

Is there any way to go from text to Enum or from integer to Enum without going through ridiculous amounts of coding? (Visual Basic 6)


Text Value Of Enum?
Hello all

I have this

Code:Public Enum EnumCompagnie
    coLassonde = 0
    coRonald = 1
End Enum

Public ecCompagnie As EnumCompagnie

If ecCompagnie equal 0, for example... is there any way that i can retrieve the value "coLassonde" so that i can, for example, print it out on a form? User won't understand that 0 is the company Lassonde... is it possible?

Thank you in advance

According to my calculations the problem doesn't exist.

Parse Text File Into Excel With VBA For Excel 2000
I am attempting to code a command button on an Excel spreadsheet to import and parse a text file into columns. The file is fixed width. If the user pressing the command button again (to import a 2nd text file), I want those records to append to the bottom of the Excel spreadsheet after the last record of the first import. However, my current code posts the records of the 2nd import into the records of the first import. It creates additional columns to accomodate the additional information. Since I search the workbook for the first empty cell and set the destination of the Query Table to this empty cell, I cannot understand why the records are added to the wrong rows. Any suggestions/comments/ideas would be greatly appreciated. Thank you!!!

Code:Private Sub btnImportCOA_Click()
'Import USPS ACS file

'******Variable declaration************************************************************
    Const FOR_READING = 1 'OpenTextFile method - Read Only parameter
    Const INT_FIRST_COL = 5 'Starting column for imported records - as integer
    Const STR_FIRST_COL = "E" 'Starting column for imported records - as char
    'File-handling variables
    Dim FileToImport 'User-selected file to import
    Dim ValidFile As Boolean 'Flag indicating if user chose a valid file
    Dim fs 'File System Object
    Dim ts 'Text Stream Object
    'Header record processing variables
    Dim strHeader As String 'Header record from import file
    'Record-handling variables
    Dim FirstRow As Integer 'First row available to be used for imported records
        FirstRow = 5
    Dim qtCOA As QueryTable 'Query table built with external data from import file
'******Variable declaration************************************************************
    'Prompt user for import file
    FileToImport = Application.GetOpenFilename(, , "Choose COA file to import...", , False)
    'Quit processing if user clicked 'Cancel' button on dialog box
    If FileToImport = False Then 'user clicked 'Cancel' button
        Exit Sub 'no file to process
    End If
    'Determine first available open cell to append records to end of recordset
    While Worksheets("COA").Range(STR_FIRST_COL & FirstRow).Value <> ""
        FirstRow = FirstRow + 1
    'Parse file into records
    Set shCOA = Workbooks(1).Worksheets(1)
    Set qtCOA = shCOA.QueryTables.Add(Connection:="TEXT;" & FileToImport, Destination:=shCOA.Cells(INT_FIRST_COL, FirstRow))
    With qtCOA
        .Name = FileToImport
        .FieldNames = False
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertEntireRows
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = xlWindows
        'Ignore header row
        .TextFileStartRow = 2
        .TextFileParseType = xlFixedWidth
        .TextFileTextQualifier = xlTextQualifierNone
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
        1, 1)
        .TextFileFixedColumnWidths = Array(1, 8, 7, 16, 6, 1, 1, 3, 47, 1, 28, 60, 35, 1, 28, _
        60, 43, 66, 2, 4, 8, 1)
        .Refresh BackgroundQuery:=False
    End With
    'Keep data but delete query table

Send Text To Excel.. Have Excel Filename=Txtbox1

I'm working on a project that would paste the contents of several textboxes into an excel file. I have the sending text part down, but I would like to have the excel file automatically change it's filename to = the contents of a textbox named txtbox1. I would also like to have VB check to insure that the filename does not exist and prompt the user to change the contents of txtbox1 if that filename exists.


Edited by - MattFenner on 12/16/2003 5:30:50 PM

Enum / End Enum
I have seen many source codes for games where they have something called Enum and then a list of things, and then End Enum. What does this do?


"Soon I will answer your questions, now you will answer mine..."

Enum In VBA
i have this code in VB:
Public Enum Commodity
Gas = 0
Power = 1
Coal = 2
End Enum

I want to convert this in VBA,but VBA doesnt accept it as i have office '97,so how do i do it..VBA doesnt seem to recoginize the Enum key word


Enum Pos
My boss has given me the dubious task of creating a form with textboxes that must have a certain enum position. Is there any way to determine what a control's enumeration position will be at design time?

Enum Name
Hi there.

Does anyone know how to get an enum name (as string)?

Enum MyEnum
One = 1
Two = 2
end Enum

Dim X as MyEnum
Dim MyEnumString as String

x = One
MyEnumString = x 'this gives-me 1 but I want "One" as string


In my code I have declared an enum type

Public Enum Wdays
Monday = 0
Tuesday = 1
Wednesday = 2
Thursday = 3
Friday = 4
End Enum

I have a database that has the fields Monday, Tuesday etc. If i declare

dim MyDay As Wdays
How can I access these fields using the actual variable? eg.

rsMyRS!MyDay ' Every time MyDay is changed it will
'Access the corresponding record ie. MyDay=Monday
' then it will access rsMyRS!Monday and so on.
Also how do I increment MyDay ie from monday to tuesday and so on.
Any help would be greatly appreciated

can anybody tell me what
enum / end enum is? can you expain it??

Using Enum??
how do i use enum??
I meant add or extract infomation
I think i know how to delare it but i am not sure about adding or extracting....coz i am more familar with struct in C

Public Enum User
Name As String
Pass As String
StartDate As Date
EngScore As Integer
MathScore As Integer

End Enum

I've seen "enum" in a few pieces of code that I've looked at in the past little while and I was curious what it was used for. Could any1 tell me or perhaps give a simple example of where it could be used? Thx

Enum And End Enum
Hey, I had this same question posted in the game section but no one answered it. Anyways, what is the Enum and End Enum code? I have seen it associated with many games, but what does it do. Here is an example of some of the uses I've seen it been put to:

End Enum

Can anyone please explain it?


"Soon I will answer your questions, now you will answer mine..."

Enum In Vb
like in c++:

enum {

this possible in vb?

edit: stupid question, ::

VB Code:
Public Enum Blah' codeEnd Enum

Enum Help
Lo all, Im using alot of enum's in my project and am having to use numbers instead of the enumeration because of 'Ambigous Name' errors. I've declared my emuns like this

VB Code:
Public Enum EnumCharacterType    Player = 0    Vendor    PlayerVendor    Monster    MountEnd Enum

Ive tried declaring as private but since they are used in a UDT a module other than the one that its declared in cant see it. Any ideas on how to get round it other than calling everything different names (I have alot of None enums hehe). I know that they are like constants so if there isnt a work arround how could I 'resuse' another enum so to speak. i.e

VB Code:
Public Enum PlayerType     Player = 0     Vendor     PlayerVendor     Monsterend enum Public Enum AccountLevel    Player = 0    GameMaster    Adminend enum Type TPlayer   'blah   'blah   AccLevel as AccountLevel   Ptype as PlayerTypeend type Public Player as TPlayer 'Now this would cause an error If Player.Ptype = Player Then     'bahend if

As both are called player it would cause this error again is there a way to reuse the Player from one of them??

can anyone explain to me what Public Enum does?
i saw it in a program but i have no idea it does.

DAO And Enum`s
I have a problem using enums in a DAO query
seems that dec.m_MediaType = 1 when i am looking to match a STRING in a table.

Is there a way around this? or am i stuck putting index numbers in my access table. ?

VB Code:
rstVelocity.Index = "PrimaryKey"    rstVelocity.Seek "=", dec.m_MediaType ' NEED STRING NOTNUMBER        mDucting.Description.m_roomVelocity = rstVelocity(1) 'just in case we need it        mDucting.Description.m_cfm = rstVelocity(1) * (dec.m_roomWidth * dec.m_roomHeight)rstVelocity.Close     ' HERES MU ENUM  Public Enum MediaType    AlumOxide    Sand    StarBlast    SteelGritEnd Enum

Thanks Seahag

How Can I Use Enum
Hi all
i want to make function same as MsgBox function that when the user select this function and sened paramter the function show him the options that he can select like when we use msgbox and select the buttons type and it show me more than one options
i tried using Enum but it didn't work with me
can any one help me please
thank you

What Is An Enum?
This may sound very newbie, but what is an enumeration, and what is it's (main) purpose? A simple example would also be nice.

Thanks in advance.

Help Needed creating ENUM for a .ctl

I have declared on the general section of the UserControl Code window:

Public ENUM bgColor
myWhite = 0
myBlack = 1
myGreen = 2
... etc.

and used the ActiveX control Interface wizard to associate a new Property named bgColor to a textbox.BackColor property but it won't function (Design time), I keep getting the original colors by Microsoft.

I need to do a project with Enum's --- I need to Get the total enum's in an array and then get the enum's that are = True ..Does anyone know of an article about this stuff???

Enum&#039;s In VBA
Hi all,

I have looked through previous threads and can't find an answer to this...

For some reason I can't created Enumeration values in VBA (Excel). It works fine when I declare them in VB, but in the VB editor within Excel it won't allow the creation...

Anybody know why this is?...Is it just a reference which needs adding? How can I create Enum's in VBA?

Thanks to anybody for help

Why does this return a type mismatch error?

Enum frTags
HEADO = "<head>"
BODYO = "<body>"
HEADC = "</head>"
BODYC = "</body>"
End Enum

Can enumerated constants only be numeric?

Enum In VB4?
I'm trying to follow a coding example in VB5 and the words

private enum

end enum

are used in the declarations of a module. Isn there a VB4 equivelency?

Old Man

Enum In VB4?
I'm trying to follow a coding example in VB5 and the words

private enum ...end enum

are used in the declarations section of a module. Is there a VB4 equivelency?

Old Man

What Is An Enum?
what is an enum or an enumeration?

Parsing Specific Text Pattern From A Text File And Save It On Excel Format
I just registered as a new member for this forum....i'm only starting to learn VB and hope i can get more information and tips from you guys. Anyone here can help me how to parse specific text pattern and save it on an Excel file?....


My text file would look like this:

Device_name : W8510HA7-BAN-C
Lot No. :14023562.1-Q45218.1
TestProgram :W8510A7_REV06_100C

 FAIL 12 25 12 10.00% Leakage Fail
 FAIL 13 26 42 42.02% bandgap Test Fail
 FAIL 14 27 100 70.11% scan_core Fail

I want to parse the value for the Device_name, Lot No., TestProgram and all others
like QTY and TEST ITEM into an predefined excel format( ex.A1evice_Name, A2:Lot No., ......etc).

I hope you can help....thanks!



Go From Enum To Strings?
Is it possible to go from an enum type to a string? For example, I have this enum:

Public Enum GenderType
Male = 0
End Enum
Is it possible for a function to take a variable of GenderType as an argument, and then get to the string "Male" or "Female" based on whether the variable is 0 or 1? I mean besides doing an if/else or select statement. I'd like to use that maneuver on fairly large enums, so i'd rather use something automatic.


Enum To Array
I want to populate the array with values from enum. How can this be done? Number of elements in enum & array are equal.
Also, I how can I set the array size equal to number of elements in enum?

Needed: Help With Enum
whats up peoples?
my final is tomorrow for vb 6.0 and the teach gave us some extra credit which i don't really have to do. but for my better understanding i'm giving it a crack. i wanted to know if someone could explain a lil better what the purpose of an enum is...
(private/public enum name
membername = constantexpression)

also, in the e.c. i'm making a parent/child MDI project where pennies, nickels, dimes, quaters get added into a batchtotal. i wanted to know if i would need to use the enum to get the values of all the child forms into another form displaying the total of all the children's values.

Enum In Paramarray
is it possible to use an enum in a paramarray - i.e. when the user tries to enter values for a paramarray, the list appears with the choices from the enum?
edit: also, when you set the backcolour of a picture box with a hex colour, then read it back, it is some long number. does anyone know how to convert hex to this?
thanks again

ENUM String
Trying something new here and having a bit of a problem.

I declare an Enumerator

Private Enum TableNames
TableName_DOC = "TB_DOC"
TableName_CCA = "TB_CCA"
TableName_CCD = "TB_CCD"
TableName_PRO = "TB_PRO"
TableName_PRD = "TB_PRD"
End Enum

But when I call the enumerator as an input to a function I get a type mismatch error.

Public Function GetNextKey(strTableNames As TableNames) As String

Is it because Enums can not contain strings or something else entirely?


String &lt;----&gt; Enum
How can I convert a string to its corresponding enum value in visual basic 6? I have a textbox and I want the user to be able to enter the info into the text box and then if it is "fish" it will go to How do I do this? I was thinking of looping through the enum values, but how do you loop? I was thinking of casting the string, but how does one cast in VB6? There is no posibilty of using a big if statement or select statement becausae there are over 150 values in the enum, so what do I do? Preferably, I would use a combobox with the choises of the enum values. But how would I do this?

Enum And Type
How are enum or type statments used in visual basic? As in, how are they implemented into a program and what is their purpose? They're confusing me

Enum Quastion
I have declared an Enum:

Public Enum mon
Jan = 1
Feb = 2
Mar = 3
Apr = 4
May = 5
Jun = 6
Jul = 7
Aug = 8
Sep = 9
Oct = 10
Nov = 11
Dec = 12
End Enum

I want to be able to compare between month that are in strings (f.e m="Feb" , c="Jan")
how can i do it?

Enum Problem Again!
The following loop is meant to go through the days of the working week, monday - friday. If rsMyRS!Monday < rsMyRS2!Monday then found will remain false. If rsMyRS!Tuesday < rsMyRS2!Monday then found will remain false and so on for the other days. My original (ugly) code for this was:

For i = 1 To 5
Select Case i
Case 1
If rsMyRS!Monday < rsMyRS2!Monday Then Found = False
Case 2
If rsMyRS!Tuesday < rsMyRS2!Tuesday Then Found = False
Case 3
If rsMyRS!Wednesday < rsMyRS2!Wednesday Then Found = False
Case 4
If rsMyRS!Thursday < rsMyRS2!Thursday Then Found = False
Case 5
If rsMyRS!Friday < rsMyRS2!Friday Then Found = False
End Select
Next i
Instead of using that code I declared an enum type as follows

Public Enum Wdays
End Enum
And used the following do loop to replace the for loop.

Do While MyDay < Wdays.Saturday
If rsMyRS.Fields(MyDay).Value < rsMyRS2.Fields.Item(MyDay).Value Then Found = False
MyDay = (MyDay + 1) Mod 6
My code doesnt do as it is supposed to. When i debug the do loop it works when MyDay = Monday. But after it is incremented the then statement is always false. Even though i know for a fact the data is true for all cases. What am i doing wrong?

Enum, Class?
I was just wondering if someone could give me a little advice if possible?

-First, I was wondering if there is anyway to create a variable that holds other variables. Something like a class that has no other purpose except holding 2 variables. Can an enum do this? I would use a class, but it seems overkill to create a class just for 2 variables.

-Second, is it possible to create instances of the above variable/class so that I can iterate through the instances based on the order in which they were created?

I'm trying to create a directory structure of a remote computer, starting at a specified domain root directory, and the logic is killing me. This is for an FTP program.

Returning Enum

Enum type_Defcon
blue = -1
green = 0
yellow = 1
red = 2
End Enum

Public Defcon As type_Defcon

Private Sub Form_Click()
Defcon = Defcon + 1
If Defcon > 2 Then Defcon = -1
Debug.Print Defcon
End Sub
This will print the value of Defcon. But how can I print the names? like blue, green etc.

Why Use Enum Instead Of Constants
What are the differences between constants and Enums?

Why should i use the enum instead just o bunch of constants to determine states.

what are the pro's and con's?

How Do You Use Enum Variables
How do you change the value of Enum variables and return its value?

Enum Modemstate
Modem_Off = 0
Modem_On = 1
End Enum
When i put this into a module and the next code into a form, it doesn't work:

Private Sub Command1_Click()
If FishState = Modem_on Then
FishState = Modem_Off
FishState = Modem_on
End If
End Sub

Private Sub Command2_Click()
MsgBox FishState
End Sub
i get a mismatch errors

Type Enum
I'd like to write something like that :

Public Enum TwDAT As Short
' DAT_....
Null= 0x0000
Capability= 0x000C
Event= 0x0002
Identity= 0x0003
Parent= 0x0004
PendingXfers= 0x0005
SetupMemXfer= 0x000B
SetupFileXfer= 0x000A

End Enum

Is it possible with vb 6.0 to use Short and this syntax ?
If not, how could I do?

Print Enum Value Name
if i have an enum type:

Public Enum foo
End Enum
i get "1" if i do "debug.print"

how do i do the reverse (get "bar" from "1")?

VB6 [Enum] To Strings
I've looked all over for documentation about how to retrieve the string representation for an enum, but despite compiling, my rendition below raises the 'Object required' error when executed.

Anyone familiar with this who can shed some light on the required arguments?

Public Function Get_FOEnum(EnumIndex As FinancialObjectType) As String
Dim v

Get_FOEnum = [Enum].getName(v, EnumIndex)

End Function

Enum Constant The Other Way
is there a way to take a enumerated constant and get the string equivalent like 24 = acPolyline???, if a function returns me a number, how do I get it's constant text description??

Enum And Its Point
what does Enum do? here's the code i am working with:

Res320x240 = 1
Res640x480 = 2
Res800x600 = 3
Res1024x768 = 4
End Enum

Public Function CreateWindow(byref frm as Form, ByVal res as RESOLUTIONS) as Form


Select Case res
Case Res320x240
frm.width = 320 * Screen.TwipsPerPixelX
frm.height = 240 * screen.twipsperpixelY

'and so on for 800x600 and 1024x768

Enum Question ???
hi All,
How can i put space in Enum constants' Name
like we have for BorderStyle for Form..

None = 0
Fixed Dialog
Fixed ToolWindow
Fixed Single

It shows me error as soon as i type such constant name

Is it a tric......can we do it???

Enum Question
You know how when you make an Enum and assign a variable or argument to it, a little popup boxs comes up when you press "=" or "(" so you can easily select a member from that Enum? Is it possible to do that with array subscripts? Like Dim an array, then when you want to refer to it you'd type "ArrayName(" and then the Enum thing would pop up?

Enum Windows
im using the enumwindows function to return a list of the windows running, but it returns all the processes running at the time. How do i filter this using the enumwindows API, and something else, like a function to tell whether the window is actually visible, and check it using that, or a different function to enumwindows, to only return visible windows. All i need to return from it is the HWND of the window.

Any help is appreciated


Copyright 2005-08, All rights reserved