Announcement

Collapse
No announcement yet.

Question on GetDeviceEnumerator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Question on GetDeviceEnumerator

    I'm working on a new script that needs to access HS devices and I'm using the following sample code:

    Code:
                Dim dv As Scheduler.Classes.DeviceClass
                Dim EN As Scheduler.Classes.clsDeviceEnumeration
    
                EN = hs.GetDeviceEnumerator
    
                If EN Is Nothing Then
                    hs.WriteLog("Error", "Error getting Enumerator")
                    Exit Sub
                End If
    In the tenscriptingHS4 environment, Visual Studio gives me the following error for the third statement:

    Option Strict On disallows implicit conversions from Object to clsDeviceEnumeration

    I can see that hs.GetDeviceEnumerator returns an Object.

    The recommended fix is to wrap it with a CTYPE.

    Code:
    EN = CType(hs.GetDeviceEnumerator, Classes.clsDeviceEnumeration)
    This seems a bit awkward. Is there a better way to do this?
    "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

    #2
    That is how I do explicit type conversion. Compiler option is to turn strict off if you do not want the awareness of implicit type conversions.

    Comment


      #3
      Originally posted by Michael McSharry View Post
      That is how I do explicit type conversion. Compiler option is to turn strict off if you do not want the awareness of implicit type conversions.
      Thanks Michael. I'll use that then. I prefer to leave strict on as it helps keep me from doing an unintentional conversion.
      "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

      Comment

      Working...
      X