Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Type casting in VB

Type casting in VB

Scheduled Pinned Locked Moved Visual Basic
helpquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lnong
    wrote on last edited by
    #1

    I'm working with VBScript and WMI Win32 classes. The Win32_USBControllerDevice.Dependent property returns a reference to a CIM_LogicalDevice object. However, I am not able to (maybe because I dont know how) invoke any CIM_LogicalDevice property or method using that reference. I thought the "dot" notation would work but it gave me an error. Here is the code: (I'm trying to call the "Name" property of CIM_LogicalDevice class) Set USB_Devices = WMI_Services.ExecQuery("Select * from Win32_USBControllerDevice") For each USB_Device in USB_Devices WScript.Echo "USB Device: " & USB_Device.Dependent.Name Next The error I got is: "ERROR: Object required: 'USB_Device.Dependent' CODE: 800A01A8" Can someone please help?

    D 1 Reply Last reply
    0
    • L lnong

      I'm working with VBScript and WMI Win32 classes. The Win32_USBControllerDevice.Dependent property returns a reference to a CIM_LogicalDevice object. However, I am not able to (maybe because I dont know how) invoke any CIM_LogicalDevice property or method using that reference. I thought the "dot" notation would work but it gave me an error. Here is the code: (I'm trying to call the "Name" property of CIM_LogicalDevice class) Set USB_Devices = WMI_Services.ExecQuery("Select * from Win32_USBControllerDevice") For each USB_Device in USB_Devices WScript.Echo "USB Device: " & USB_Device.Dependent.Name Next The error I got is: "ERROR: Object required: 'USB_Device.Dependent' CODE: 800A01A8" Can someone please help?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Well, you can't use a ref: object like that, as you've already found out, since the WMI provider won't resolve reference for you. But, the CIM_LogicalDevice maps to a Win32_PnPEntity object. You can use the string that Dependant returns to get at the actual device. You'll have to parse out the DeviceID, but you can use that ID to get the appropriate Win32_PnPEntity object from WMI. RageInTheMachine9532

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups