locked
Code conversion problem RRS feed

  • Question

  • User559005402 posted

    Given this code:

    		Private Function BackToParentMenu(ByVal mnu As Menu) As Boolean
    			' 
    			If mnu.parentMenu = lstMenus(0) Then
    				Return False
    			End If
    			For Each mi As MenuItem In mnu.lstMenuItems
    				If mi.mousePos.X <> -1 AndAlso (mi.mousePos.X < mnu.Width * 15 / 100) Then
    					Return True
    				End If
    			Next
    			Return False
    		End Function


     What does it mean when on the first IF it says

     "Operator '=' is not defined for types 'SilverlightApplication1.glMenu.Menu'"?

     

    Thanks

    Thursday, April 15, 2010 2:30 PM

Answers

  • User-952121411 posted

    I don't have a Silverlight Project currently wired up with that object type (Menu I believe), but see if the 'parentMenu' item exposes an 'Equals' method like below:

    If mnu.parentMenu.Equals(lstMenus(0)) Then 


     

    The previous comments were correct about Reference types in VB.NET, but do not confuse for your code snippet about your '<>' comparison.  That does not need to be changed as mousePos.'X' is a type of Double, so the comparison to -1 should be fine.  You may have already understood this as your question was in fact only in regards to the 1st 'If' statement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 16, 2010 9:28 AM

All replies

  • User397347636 posted

    For reference types in VB, you need to use "Is" to compare them, not "=" (and "IsNot" instead of "<>").

     

    Thursday, April 15, 2010 6:06 PM
  • User-952121411 posted

    I don't have a Silverlight Project currently wired up with that object type (Menu I believe), but see if the 'parentMenu' item exposes an 'Equals' method like below:

    If mnu.parentMenu.Equals(lstMenus(0)) Then 


     

    The previous comments were correct about Reference types in VB.NET, but do not confuse for your code snippet about your '<>' comparison.  That does not need to be changed as mousePos.'X' is a type of Double, so the comparison to -1 should be fine.  You may have already understood this as your question was in fact only in regards to the 1st 'If' statement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 16, 2010 9:28 AM