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
Get_FOEnum = [Enum].getName(v, EnumIndex)
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
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.
Strings In Enum Block???
Enumerators are an excellent way of orginising your constants, but what if i want a enumerator of string contants???
Public Enum a = "qwertyuiop" b = "asdfghjkl" c = "zxcvbnm"End Enum
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
Parsing Long Text Strings Into Shorter Strings
Any help on the following would be greatly appreciated!
I need to split a long text string (variable in length) into shorter strings which are no more than 60 (or X) characters in length, but only breaking on full words (i.e. no hyphenation).
Example: The target string could be a full paragragh such as: "Customer called and wanted to know how to post invoices using a past invoice date, and yet age the invoices as of a future invoice date. I told her this would violate the integrity of her accounts receivable system, but would contact one of our systems analysts regarding a quote on the number of hours required. I informed her I would send out a software modification agreement to her within one (1) week.”
I need to break it into shorter strings (of X length, in this case 60) which I can use and insert into other text fields. The above paragraph would be parsed into separate strings as follows:
“Customer called and wanted to know how to post invoices ”
“using a past invoice date, and yet age the invoices as of a “
“future invoice date. I told her this would violate the “
“integrity of her accounts receivable system, but would “
“contact one of our systems analysts regarding a quote on “
“the number of hours required. I informed her I would send “
“out a software modification agreement to her within one (1) “
Thanks for your help!
How To Extract Strings From Within Other Strings With The Use Of Delimiters
I have put a web page's html code into a string and now I am trying to extract a string from within that string. I.E. I need to get access to the meta tags. These are denoted by the following
<meta name "keywords" content = $$$, $$$, $$$, $$$ ......>
I was hoping to be able to extract this string by using the < and > as delimiters. Can this be done? Grateful for any help.
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
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
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?
Does anyone know how to get an enum name (as string)?
One = 1
Two = 2
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
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??
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
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:
Can anyone please explain it?
"Soon I will answer your questions, now you will answer mine..."
Enum In Vb
like in c++:
this possible in vb?
edit: stupid question, ::
Public Enum Blah' codeEnd Enum
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
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
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. ?
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
How Can I Use Enum
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
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
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's In VBA
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?
HEADO = "<head>"
BODYO = "<body>"
HEADC = "</head>"
BODYC = "</body>"
Can enumerated constants only be numeric?
Enum In VB4?
I'm trying to follow a coding example in VB5 and the words
are used in the declarations of a module. Isn there a VB4 equivelency?
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?
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?
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"
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 <----> 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 animals.fish. 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
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
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
If rsMyRS!Monday < rsMyRS2!Monday Then Found = False
If rsMyRS!Tuesday < rsMyRS2!Tuesday Then Found = False
If rsMyRS!Wednesday < rsMyRS2!Wednesday Then Found = False
If rsMyRS!Thursday < rsMyRS2!Thursday Then Found = False
If rsMyRS!Friday < rsMyRS2!Friday Then Found = False
Instead of using that code I declared an enum type as follows
Public Enum Wdays
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?
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.
blue = -1
green = 0
yellow = 1
red = 2
Public Defcon As type_Defcon
Private Sub Form_Click()
Defcon = Defcon + 1
If Defcon > 2 Then Defcon = -1
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?
Modem_Off = 0
Modem_On = 1
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
Private Sub Command2_Click()
i get a mismatch errors
I'd like to write something like that :
Public Enum TwDAT As Short
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
i get "1" if i do "debug.print foo.bar"
how do i do the reverse (get "bar" from "1")?
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:
Public Enum RESOLUTIONS
Res320x240 = 1
Res640x480 = 2
Res800x600 = 3
Res1024x768 = 4
Public Function CreateWindow(byref frm as Form, ByVal res as RESOLUTIONS) as Form
Select Case res
frm.width = 320 * Screen.TwipsPerPixelX
frm.height = 240 * screen.twipsperpixelY
'and so on for 800x600 and 1024x768
Enum Question ???
How can i put space in Enum constants' Name
like we have for BorderStyle for Form..
None = 0
It shows me error as soon as i type such constant name
Is it a tric......can we do it???
From Text To Enum (VB6)
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
coEquals = 0
coGreaterThan = 1
coGreaterThanEqualTo = 2
coLessThan = 3
coLessThanEqualTo = 4
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)
Public Function GetpObjectRef(s As String) As pObjectRef
Select Case s
GetpObjectRef = orRef
GetpObjectRef = orAll
GetpObjectRef = orNone
GetpObjectRef = orAtLeastOne
GetpObjectRef = orExactlyOne
GetpObjectRef = orEqualToRefNum
GetpObjectRef = orGreaterThanRefNum
GetpObjectRef = orGreaterThanEqualToRefNum
GetpObjectRef = orLessThanRefNum
GetpObjectRef = orLessThanEqualToRefNum
GetpObjectRef = orRef
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)
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?
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
I am having a problem with my Enum statement in one of my modules. I have a statement:
Public Enum Movement
None = 0
Up = 1
Down = 2
Left = 3
Right = 4
Sword = 5
Public Type UDTGame
Move As Movement
Lives As Integer
CurrentBoard As Board
Public Game As UDTGame
In a Form_KeyDown sub routine, I have:
If KeyCode = vbKeyLeft Then
Game.Move = Left
The problem is that it is not picking up Left. When I step through the debugger, it is putting Game.Move = 7170 instead of 3. Every other movement Enum works fine and have the appropriate numbers. Does anyone know why?