Results 1 to 26 of 26

Thread: [RESOLVED] Run-time error '6': Overflow

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    [RESOLVED] Run-time error '6': Overflow

    I colored the line that errors in red. I have NO idea what the hell is wrong. :'(
    VB Code:
    1. Option Explicit
    2. Type TypeDiskDrive
    3.     InterfaceType As String
    4.     Partitions As Long
    5.     Size As Long
    6.     Status As String
    7. End Type
    8. Public DiskDrives As TypeDiskDrive
    9. Sub Main()
    10.    Debug.Print "MDiskDrives->Main();"
    11. End Sub
    12. Public Sub Win32_DiskDrive()
    13.     Debug.Print "MDiskDrives->Win32_DiskDrive();"
    14.     Dim CIMV2 As Object
    15.     Dim Result As Object
    16.     Dim Row As Object
    17.     Set CIMV2 = GetObject("winmgmts:\\127.0.0.1\root\CIMV2")
    18.     Set Result = CIMV2.ExecQuery("SELECT InterfaceType, Partitions, Size, Status FROM Win32_DiskDrive", "WQL", &H10 + &H20)
    19.     For Each Row In Result
    20.         MsgBox Row.Size
    21.         DiskDrives.InterfaceType = Row.InterfaceType
    22.         DiskDrives.Partitions = Row.Partitions
    23.         [COLOR=Red]DiskDrives.Size = Row.Size[/COLOR]
    24.         DiskDrives.Status = Row.Status
    25.     Next
    26. End Sub
    Last edited by frozen; Nov 5th, 2005 at 03:24 AM. Reason: :D

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Run-time error '6': Overflow

    If I remember correctly the Row.Size would be a 64-bit Integer while a Long is just 32-bit. Try to declare your Size member as Currency since that is basically a 64-bit integer however when you print it is divided with 10000 when it is displayed. But you can do some calculation around that.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    Now I am getting Run-time error '-2147217385 (80041017)': Automation error on the red For Each...
    VB Code:
    1. Option Explicit
    2. Public Type TypeNetworkAdapter
    3.     Name As String
    4. End Type
    5. Public NetworkAdapters As TypeNetworkAdapter
    6. Sub Main()
    7.    Debug.Print "MNetworkAdapters->Main();"
    8. End Sub
    9. Public Sub Win32_NetworkAdapters()
    10.     Debug.Print "MNetworkAdapters->Win32_NetworkAdapter();"
    11.     Dim CIMV2 As Object
    12.     Dim Result As Object
    13.     Dim Row As Object
    14.     Set CIMV2 = GetObject("winmgmts:\\127.0.0.1\root\CIMV2")
    15.     Set Result = CIMV2.ExecQuery("SELECT InterfaceType, Name FROM Win32_NetworkAdapter", "WQL", &H10 + &H20)
    16.     [COLOR=Red]For Each Row In Result[/COLOR]
    17.         If Row.InterfaceType = "Ethernet 802.3" Then
    18.             NetworkAdapters.Name = Row.Name
    19.         End If
    20.     Next
    21. End Sub

  4. #4
    Hyperactive Member hassa046's Avatar
    Join Date
    May 2001
    Location
    Venlo, The Netherlands
    Posts
    336

    Re: Run-time error '6': Overflow

    i guess that row cannot be a member of result. Try to find out what kind of value (int,lng or byte) you get from CIMV2 and what is Row.

    I think it has to do with different types.
    Better to regret things you did, than those you didn't
    International Intelligence

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    They are all Objects :|

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Run-time error '6': Overflow

    Scriptomatic2 does it like this:
    Save it as a .vbs file, and run with Internet Explorer, or use Cscript.exe

    VB Code:
    1. On Error Resume Next
    2.  
    3. Const wbemFlagReturnImmediately = &h10
    4. Const wbemFlagForwardOnly = &h20
    5.  
    6. arrComputers = Array".")
    7. For Each strComputer In arrComputers
    8.    WScript.Echo
    9.    WScript.Echo "=========================================="
    10.    WScript.Echo "Computer: " & strComputer
    11.    WScript.Echo "=========================================="
    12.  
    13.    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    14.    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
    15.                                           wbemFlagReturnImmediately + wbemFlagForwardOnly)
    16.  
    17.    For Each objItem In colItems
    18.       WScript.Echo "AdapterType: " & objItem.AdapterType
    19.       WScript.Echo "AdapterTypeId: " & objItem.AdapterTypeId
    20.       WScript.Echo "AutoSense: " & objItem.AutoSense
    21.       WScript.Echo "Availability: " & objItem.Availability
    22.       WScript.Echo "Caption: " & objItem.Caption
    23.       WScript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
    24.       WScript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
    25.       WScript.Echo "CreationClassName: " & objItem.CreationClassName
    26.       WScript.Echo "Description: " & objItem.Description
    27.       WScript.Echo "DeviceID: " & objItem.DeviceID
    28.       WScript.Echo "ErrorCleared: " & objItem.ErrorCleared
    29.       WScript.Echo "ErrorDescription: " & objItem.ErrorDescription
    30.       WScript.Echo "Index: " & objItem.Index
    31.       WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate)
    32.       WScript.Echo "Installed: " & objItem.Installed
    33.       WScript.Echo "LastErrorCode: " & objItem.LastErrorCode
    34.       WScript.Echo "MACAddress: " & objItem.MACAddress
    35.       WScript.Echo "Manufacturer: " & objItem.Manufacturer
    36.       WScript.Echo "MaxNumberControlled: " & objItem.MaxNumberControlled
    37.       WScript.Echo "MaxSpeed: " & objItem.MaxSpeed
    38.       WScript.Echo "Name: " & objItem.Name
    39.       WScript.Echo "NetConnectionID: " & objItem.NetConnectionID
    40.       WScript.Echo "NetConnectionStatus: " & objItem.NetConnectionStatus
    41.       strNetworkAddresses = Join(objItem.NetworkAddresses, ",")
    42.          WScript.Echo "NetworkAddresses: " & strNetworkAddresses
    43.       WScript.Echo "PermanentAddress: " & objItem.PermanentAddress
    44.       WScript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
    45.       strPowerManagementCapabilities = Join(objItem.PowerManagementCapabilities, ",")
    46.          WScript.Echo "PowerManagementCapabilities: " & strPowerManagementCapabilities
    47.       WScript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
    48.       WScript.Echo "ProductName: " & objItem.ProductName
    49.       WScript.Echo "ServiceName: " & objItem.ServiceName
    50.       WScript.Echo "Speed: " & objItem.Speed
    51.       WScript.Echo "Status: " & objItem.Status
    52.       WScript.Echo "StatusInfo: " & objItem.StatusInfo
    53.       WScript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
    54.       WScript.Echo "SystemName: " & objItem.SystemName
    55.       WScript.Echo "TimeOfLastReset: " & WMIDateStringToDate(objItem.TimeOfLastReset)
    56.       WScript.Echo
    57.    Next
    58. Next
    59.  
    60.  
    61. Function WMIDateStringToDate(dtmDate)
    62. WScript.Echo dtm:
    63.     WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
    64.     Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
    65.     & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
    66. End Function

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    ....

  8. #8
    Hyperactive Member hassa046's Avatar
    Join Date
    May 2001
    Location
    Venlo, The Netherlands
    Posts
    336

    Re: Run-time error '6': Overflow

    Quote Originally Posted by frozen
    They are all Objects :|
    Objects can contain different types.(variants, strings, integers, my own defined types, etc....)
    You need to convert them probably to one and another.
    Better to regret things you did, than those you didn't
    International Intelligence

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Run-time error '6': Overflow

    Quote Originally Posted by frozen
    They are all Objects :|
    After this line
    VB Code:
    1. Set Result = CIMV2.ExecQuery("SELECT InterfaceType, Name FROM Win32_NetworkAdapter", "WQL", &H10 + &H20)
    go in to the Immediate window and type
    VB Code:
    1. ?typename(Result)
    and see what it says.

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Run-time error '6': Overflow

    Quote Originally Posted by hassa046
    Objects can contain different types.(variants, strings, integers, my own defined types, etc....)
    You need to convert them probably to one and another.
    Objects are generic objects whos interface is obtained after they are cast to specific objects. They cannot "contain" other types - that is what Variants do.

  11. #11
    Hyperactive Member hassa046's Avatar
    Join Date
    May 2001
    Location
    Venlo, The Netherlands
    Posts
    336

    Re: Run-time error '6': Overflow

    Hmm. Are you sure?
    I have a class with several function (like Autostr) Class1.
    Together with other classes it has become an object. Lets say Program1

    In program 2 i want to use an autogenerated string called Autostr
    First i make an empty object
    Dim P1 as object
    Set P1 = createobject(Program1.Class1)

    So P1 becomes the class1 object

    but when i use P1 as P1.Autostr then it gives me a string as result.
    Thats what i ment.
    Better to regret things you did, than those you didn't
    International Intelligence

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Run-time error '6': Overflow

    That's completely different. Upon your "Set P1 = " line you cast the generic P1 object to a reference to Program1.Class1 and obtain the interface for that class (The interface contains all the methods, properties etc). Autostr must be a string-typed member of Class1.

    Variants, on the other hand, CAN contain other variables.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    penagate: SWbemObjectSet

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    Quote Originally Posted by frozen
    Run-time error '-2147217385 (80041017)': Automation error on the red For Each...
    VB Code:
    1. Option Explicit
    2. Public Type TypeNetworkAdapter
    3.     Name As String
    4. End Type
    5. Public NetworkAdapters As TypeNetworkAdapter
    6. Sub Main()
    7.    Debug.Print "MNetworkAdapters->Main();"
    8. End Sub
    9. Public Sub Win32_NetworkAdapters()
    10.     Debug.Print "MNetworkAdapters->Win32_NetworkAdapter();"
    11.     Dim CIMV2 As Object
    12.     Dim Result As Object
    13.     Dim Row As Object
    14.     Set CIMV2 = GetObject("winmgmts:\\127.0.0.1\root\CIMV2")
    15.     Set Result = CIMV2.ExecQuery("SELECT InterfaceType, Name FROM Win32_NetworkAdapter", "WQL", &H10 + &H20)
    16.     [COLOR=Red]For Each Row In Result[/COLOR]
    17.         If Row.InterfaceType = "Ethernet 802.3" Then
    18.             NetworkAdapters.Name = Row.Name
    19.         End If
    20.     Next
    21. End Sub
    Still stuck here...

  15. #15
    Hyperactive Member hassa046's Avatar
    Join Date
    May 2001
    Location
    Venlo, The Netherlands
    Posts
    336

    Re: Run-time error '6': Overflow

    Try this:

    VB Code:
    1. Option Explicit
    2. Public Type TypeNetworkAdapter
    3.     Name As String
    4. End Type
    5. Public NetworkAdapters As TypeNetworkAdapter
    6. Sub Main()
    7.    Debug.Print "MNetworkAdapters->Main();"
    8. End Sub
    9. Public Sub Win32_NetworkAdapters()
    10.     Debug.Print "MNetworkAdapters->Win32_NetworkAdapter();"
    11.     Dim CIMV2 As Object
    12.     Dim Result As Variant
    13.     Dim Row As Variant
    14.     Set CIMV2 = GetObject("winmgmts:\\127.0.0.1\root\CIMV2")
    15.     Set Result = CIMV2.ExecQuery("SELECT InterfaceType, Name FROM
    16. Win32_NetworkAdapter", "WQL", &H10 + &H20)
    17.     For Each Row In Result
    18.         If Row.InterfaceType = "Ethernet 802.3" Then
    19.             NetworkAdapters.Name = Row.Name
    20.         End If
    21.     Next
    22. End Sub
    Better to regret things you did, than those you didn't
    International Intelligence

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    Changes nothing

  17. #17
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Run-time error '6': Overflow

    The error is because the Win32_NetworkAdapter WMI object doesn't have an InterfaceType property so the result is a NULL object and you can't use a For Each loop on that.

    EDIT: What you should look for is the AdapterType instead. So the end of your code should look like this:
    VB Code:
    1. Set Result = CIMV2.ExecQuery("SELECT AdapterType, Name FROM Win32_NetworkAdapter", "WQL", &H10 + &H20)
    2. For Each Row In Result
    3.     If Row.AdapterType = "Ethernet 802.3" Then
    4.         NetworkAdapters.Name = Row.Name
    5.     End If
    6. Next
    Last edited by Joacim Andersson; Nov 5th, 2005 at 01:26 AM.

  18. #18
    Hyperactive Member hassa046's Avatar
    Join Date
    May 2001
    Location
    Venlo, The Netherlands
    Posts
    336

    Re: Run-time error '6': Overflow

    http://msdn.microsoft.com/library/de...r_hardware.asp

    both declared as object

    VB Code:
    1. Set CIMV2 = GetObject("winmgmts:\\127.0.0.1\root\CIMV2")
    2.     Set results = CIMV2.ExecQuery("SELECT AdapterType, Name FROM Win32_NetworkAdapter", "WQL", &H10 + &H20)


    I saw that Joacim also found the error.
    Better to regret things you did, than those you didn't
    International Intelligence

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    Ty! :d

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    Whats a tape drive? lol

  21. #21
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Run-time error '6': Overflow

    Quote Originally Posted by Joacim Andersson
    The error is because the Win32_NetworkAdapter WMI object doesn't have an InterfaceType property so the result is a NULL object and you can't use a For Each loop on that.

    EDIT: What you should look for is the AdapterType instead. So the end of your code should look like this:
    VB Code:
    1. Set Result = CIMV2.ExecQuery("SELECT AdapterType, Name FROM Win32_NetworkAdapter", "WQL", &H10 + &H20)
    2. For Each Row In Result
    3.     If Row.AdapterType = "Ethernet 802.3" Then
    4.         NetworkAdapters.Name = Row.Name
    5.     End If
    6. Next
    I guess that works, but you're still using For Each...?

  22. #22
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Run-time error '6': Overflow


  23. #23
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Run-time error '6': Overflow

    Quote Originally Posted by penagate
    I guess that works, but you're still using For Each...?
    Yes... Because I use the correct SQL statement in the call I get a correct object and you can use For Each on WMI objects.

  24. #24
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Run-time error '6': Overflow

    Oh, I didn't notice the SQL statement was changed. I understand now

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Run-time error '6': Overflow

    This is getting off topic but I think it will be my last question so I won't make a new topic for it.
    I'm now trying to detect the mouse, Win32_PointingDevice gives me two and I see no item to seperate the _real_ one from the _fake_ one
    Code:
    Availability: 
    Caption: HID-compliant mouse
    ConfigManagerErrorCode: 0
    ConfigManagerUserConfig: False
    CreationClassName: Win32_PointingDevice
    Description: HID-compliant mouse
    DeviceID: HID\VID_046D&PID_C309&MI_01&COL03\7&36E55074&0&0002
    DeviceInterface: 162
    DoubleSpeedThreshold: 6
    ErrorCleared: 
    ErrorDescription: 
    Handedness: 2
    HardwareType: HID-compliant mouse
    InfFileName: msmouse.inf
    InfSection: HID_Mouse_Inst
    IsLocked: 
    LastErrorCode: 
    Manufacturer: Microsoft
    Name: HID-compliant mouse
    NumberOfButtons: 5
    PNPDeviceID: HID\VID_046D&PID_C309&MI_01&COL03\7&36E55074&0&0002
    PointingType: 2
    PowerManagementCapabilities: 
    PowerManagementSupported: False
    QuadSpeedThreshold: 10
    Resolution: 
    SampleRate: 
    Status: OK
    StatusInfo: 
    Synch: 
    SystemCreationClassName: Win32_ComputerSystem
    SystemName: SAM
    
    
    Availability: 
    Caption: Microsoft USB IntelliMouse Explorer 3.0
    ConfigManagerErrorCode: 0
    ConfigManagerUserConfig: False
    CreationClassName: Win32_PointingDevice
    Description: Microsoft USB IntelliMouse Explorer 3.0
    DeviceID: USB\VID_045E&PID_0047\5&DF9F058&0&2
    DeviceInterface: 162
    DoubleSpeedThreshold: 6
    ErrorCleared: 
    ErrorDescription: 
    Handedness: 2
    HardwareType: Microsoft USB IntelliMouse Explorer 3.0
    InfFileName: input.inf
    InfSection: HID_Inst
    IsLocked: 
    LastErrorCode: 
    Manufacturer: Microsoft
    Name: Microsoft USB IntelliMouse Explorer 3.0
    NumberOfButtons: 5
    PNPDeviceID: USB\VID_045E&PID_0047\5&DF9F058&0&2
    PointingType: 2
    PowerManagementCapabilities: 
    PowerManagementSupported: False
    QuadSpeedThreshold: 10
    Resolution: 
    SampleRate: 
    Status: OK
    StatusInfo: 
    Synch: 
    SystemCreationClassName: Win32_ComputerSystem
    SystemName: SAM

  26. #26
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Run-time error '6': Overflow

    I think that gives you the drivers. As to which device is actually plugged in, you'd need to enumerate all available Devices of that type, I think.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width