?
Solved

Enum and string?

Posted on 2006-05-31
13
Medium Priority
?
920 Views
Last Modified: 2011-09-20

what i want is this:

Public Enum Con_Com
   rcon_login = "rcon login"
   rcon_serverinfo = "rcon serverinfo"
   rcon_systeminfo = "rcon systeminfo"
   rcon_status = "rcon status"
   rcon_exec = "rcon_exec "
   rcon_writeconfig = "rcon writeconfig "
   rcon_say = "rcon say "
End Enum


but that gives me an error
how should i do this?
0
Comment
Question by:Mark_FreeSoftware
13 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16799713
I think the constants must be numeric.

Public Enum Con_Com
   rcon_login = 0
   rcon_serverinfo = 1
   rcon_status = 2
   rcon_exec = 3
   rcon_writeconfig = 4
   rcon_say = 5
End Enum
0
 
LVL 15

Expert Comment

by:cquinn
ID: 16799776
The values inside the enum must map to Long integers

E.g.

Public Enum Con_Com
   rcon_login = 1
   rcon_serverinfo = 2
   rcon_systeminfo = 3
   rcon_status = 4
   rcon_exec = 5
   rcon_writeconfig = 6
   rcon_say = 7
End Enum

You can then use a Select Case statement to convert the number to the string equivalent where you use the Con_Com type
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16799787
you can use array instead

i.e.

Dim arr

arr = Array("rcon login", "rcon serverinfo", "rcon systeminfo", _
        "rcon status", "rcon_exec", "rcon writeconfig", "rcon say")
       
Debug.Print arr(1)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 13

Author Comment

by:Mark_FreeSoftware
ID: 16799827

yeah, but then it doesnt act like i want,

i want it to act like a boolean,
it pops up, and when you select true or false it prints that in the vb IDE.

but since i have spaces in it, this didnt work with a normal enum

now i try to find another way...
0
 
LVL 2

Expert Comment

by:ExtremeFitness
ID: 16799865
Maybe you need to do this with a class??

0
 
LVL 2

Accepted Solution

by:
ExtremeFitness earned 2000 total points
ID: 16799897
eg...
 in clsRcon.bas

Option Explicit

Public Property Get rcon_writeconfig() As String
    rcon_writeconfig = "rcon writeconfig "
End Property

Public Property Get rcon_say() As String
    rcon_say = "rcon say "
End Property
etc....

in form or where ever...

Private Sub Form_Load()
Dim oRc As New clsRcon
dim strX as string

strX  = oRc.rcon_say

End Sub
0
 
LVL 2

Expert Comment

by:ExtremeFitness
ID: 16799905
clsRcon.cls not clsRcon.bas
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
ID: 16799921

is that the only way?
0
 
LVL 2

Expert Comment

by:ExtremeFitness
ID: 16799934
that I know of....   are u used to object oriented (kinda) vb6?  
You can do allot that way....
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
ID: 16799956
>>are u used to object oriented (kinda) vb6?

can you explain that a little?


i do have 2.5 years vb experience if that's what you asking...
0
 
LVL 2

Expert Comment

by:ExtremeFitness
ID: 16800554
Thats quite a topic...  There are many examples on the web ex. http://www.insteptech.com/techlibrary/vbclassic/vb6_oo.htm
Although vb6 is not object oriented you can come very close.  There are many benifits for example you can have objects save thiere childeren and so you only have to save the parent.

If and when you move to vb.net you will be forced into a object oriented stype of programming....

Check it out, once you 'get-it' there is not other way to go...

0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
ID: 16800717
thanks!

then i'm going for the class.


0
 
LVL 2

Expert Comment

by:ExtremeFitness
ID: 16800783
Its actually quite easy once you get the idea...  Its worth you time to figure it out...
It will also give you insight as to how many of the vb objects work...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question