realbasic-nug
[Top] [All Lists]

Enum Casting to Enum?

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Enum Casting to Enum?
From: Karen <keatk@verizon.net>
Date: Sun, 31 May 2009 21:44:16 -0400
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
I am finishing up a little Checkbox drawing utility. I need to have an Enum with one more value than does CheckBox.CheckedState for particular function (besides "if State = CheckBox.CheckedState.UnChecked Then..." gets to be a bit long)

So I defined a Enun in that module:

Enum CheckStates As Integer
  Unchecked
  Checked
  Indeterminate
  AllStates = -1
End Enum

But I also want to support the CheckBox.CheckedState

So I overload the methods thusly:

//---------------------------------
Sub aMethod(State as CheckState)
   ...
End Sub
//---------------------------------

Sub aMethod(State as CheckBox.CheckedState)

   aMethod CheckState(State) ' <------ Gives error

End Sub
//---------------------------------

Why can't I cast a CheckBox.CheckedState to a CheckState? is it a bug?

Well I figured if that did not work this would:

  aMethod CheckState(Integer(State)) ' <------ STILL gives an error

Next I tried:

  Dim i as integer = Integer(State)
  aMethod CheckState(i)

AND that works!!!!

Have I tripped over another bug? Or is this by design?

(And yes i know I can just use a Select case- Not the point!)

- Karen





_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>