Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enumerators Not Recognized?

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
Hey guys,

I have a dll that encapsulates all the sql connectivity. I have two public enumerators within it. However, when its referenced in my code and access is attempted, visual studio flags the enumerator types in teh parameters list saying they aren't declared.

Any thoughts?

Thanks,

Jack
 
Hello Jack,
I am not quite sure how your code is actually working but the problem that you mention probably lies on the way you are "calling" the enumerator.

For example if your enumeration is called MyActualEnum defined in a classMyEnumClass.vb within a NameSpace MyEnum and you try to call it from another application you first need to add the reference to the dll on the Refrences of your new application (Add Reffernce...>Select) and then from your code you can try something like:

Dim TestEnum As MyEnum.MyEnumClass.MyActualEnumerator

I hope that this helps
"The Camel will walk the desert of programming once again ..."

Camel
 
Hey Camel,

I am referencing the DLL, but I'm trying to access the enumerator in a different way than you're thinking:
instead of actually dimming an enumerator, what I'm trying to do is just set it within the parameter list of a function. For example:

blnIsConnected = objConnect.Connection(string, ENUMERATOR)

However, I'm going to go back and see if maybe with .NET you need to actually dim an instance of the enumerator (which would be wanky since I already have an instance of the actual object created which has the enumerators declared in its general declarations of the class).

Thanks for the ideas,

jack
 
Hello Jack,
I created a small application to test the enumeration and it can work with both the "dimed" enumerators and "un-dimed".

Here is the soure for the test application:
Code:
Public Class Form1
    Inherits System.Windows.Forms.Form

'***Normal IDE stuff***

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As MyEnum.MyEnumClass.MyActualEnumerator

        'MsgBox(CInt(i.test2))
        MsgBox(MyEnum.MyEnumClass.MyActualEnumerator.test1)

    End Sub
End Class

and the enumerator:
Code:
Public Class MyEnumClass
    Public Enum MyActualEnumerator
        test1
        test2
        test3
        test4
    End Enum

End Class

I am actually running the above code (using RC1) and it works normally. I wish i could send an attachment with all the code so you could see run it straight away.

Try that and let me know if everything is ok
"The Camel will walk the desert of programming once again ..."

Camel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top