VB Code:
  1. Option Explicit
  2.  
  3. Public Enum OperationalStates
  4.     MIB_IF_OPER_STATUS_NON_OPERATIONAL = 0
  5.     MIB_IF_OPER_STATUS_UNREACHABLE = 1
  6.     MIB_IF_OPER_STATUS_DISCONNECTED = 2
  7.     MIB_IF_OPER_STATUS_CONNECTING = 3
  8.     MIB_IF_OPER_STATUS_CONNECTED = 4
  9.     MIB_IF_OPER_STATUS_OPERATIONAL = 5
  10. End Enum
  11.  
  12. Public Enum InterfaceTypes
  13.     MIB_IF_TYPE_OTHER = 1
  14.     MIB_IF_TYPE_ETHERNET = 6
  15.     MIB_IF_TYPE_TOKENRING = 9
  16.     MIB_IF_TYPE_FDDI = 15
  17.     MIB_IF_TYPE_PPP = 23
  18.     MIB_IF_TYPE_LOOPBACK = 24
  19.     MIB_IF_TYPE_SLIP = 28
  20. End Enum
  21.  
  22. Public Enum AdminStatuses
  23.     MIB_IF_ADMIN_STATUS_UP = 1
  24.     MIB_IF_ADMIN_STATUS_DOWN = 2
  25.     MIB_IF_ADMIN_STATUS_TESTING = 3
  26. End Enum
  27.  
  28. Private Const MAXLEN_IFDESCR = 256
  29. Private Const MAXLEN_PHYSADDR = 8
  30. Private Const MAX_INTERFACE_NAME_LEN = 256
  31.  
  32. Private Const ERROR_NOT_SUPPORTED = 50&
  33. Private Const ERROR_SUCCESS = 0&
  34.  
  35.  
  36. Private Type MIB_IFROW
  37.     wszName(0 To 511) As Byte
  38.     dwIndex As Long             '// index of the interface
  39.     dwType As Long              '// type of interface
  40.     dwMtu As Long               '// max transmission unit
  41.     dwSpeed As Long             '// speed of the interface
  42.     dwPhysAddrLen As Long       '// length of physical address
  43.     bPhysAddr(0 To 7) As Byte   '// physical address of adapter
  44.     dwAdminStatus As Long       '// administrative status
  45.     dwOperStatus As Long        '// operational status
  46.     dwLastChange As Long        '// last time operational status changed
  47.     dwInOctets As Long          '// octets received
  48.     dwInUcastPkts As Long       '// unicast packets received
  49.     dwInNUcastPkts As Long      '// non-unicast packets received
  50.     dwInDiscards As Long        '// received packets discarded
  51.     dwInErrors As Long          '// erroneous packets received
  52.     dwInUnknownProtos As Long   '// unknown protocol packets received
  53.     dwOutOctets As Long         '// octets sent
  54.     dwOutUcastPkts As Long      '// unicast packets sent
  55.     dwOutNUcastPkts As Long     '// non-unicast packets sent
  56.     dwOutDiscards As Long       '// outgoing packets discarded
  57.     dwOutErrors As Long         '// erroneous packets sent
  58.     dwOutQLen As Long           '// output queue length
  59.     dwDescrLen As Long          '// length of bDescr member
  60.     bDescr(0 To 255) As Byte    '// interface description
  61. End Type
  62.  
  63. Private Declare Function GetIfTable Lib "iphlpapi" (ByRef pIfRowTable As Any, ByRef pdwSize As Long, ByVal bOrder As Long) As Long
  64. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef pDest As Any, ByRef pSource As Any, ByVal Length As Long)
  65.  
  66.  
  67. Private mvarInterfaces As CInterface 'local copy
  68.  
  69. Private m_lngBytesReceived  As Long
  70. Private m_lngBytesSent      As Long
  71.  
  72. Public Property Set CInterfaces(ByVal vData As CInterfaces)
  73.     Set mvarInterfaces = vData
  74. End Property
  75.  
  76.  
  77. Public Property Get Interfaces() As CInterfaces
  78.     '
  79.     Set mvarInterfaces = Nothing
  80.     '
  81.     Set mvarInterfaces = New CInterfaces
  82.     Call InitInterfaces(mvarInterfaces)
  83.     '
  84.     Set Interfaces = mvarInterfaces
  85.     '
  86. End Property
  87.  
  88. Public Property Get BytesReceived() As Long
  89.     BytesReceived = m_lngBytesReceived
  90. End Property
  91.  
  92. Public Property Get BytesSent() As Long
  93.     BytesSent = m_lngBytesSent
  94. End Property
  95.  
  96.  
  97. Private Function InitInterfaces(objInterfaces As CInterfaces) As Boolean
  98.     '
  99.     Dim arrBuffer()     As Byte
  100.     Dim lngSize         As Long
  101.     Dim lngRetVal       As Long
  102.     Dim lngRows         As Long
  103.     Dim i               As Integer
  104.     Dim j               As Integer
  105.     Dim IfRowTable      As MIB_IFROW
  106.     Dim objInterface    As New CInterface
  107.     '
  108.     lngSize = 0
  109.     '
  110.     'Reset the BytesReceived and BytesSent properties
  111.     '
  112.     m_lngBytesReceived = 0
  113.     m_lngBytesSent = 0
  114.     '
  115.     'Call the GetIfTable just to get the buffer size into the lngSize variable
  116.     lngRetVal = GetIfTable(ByVal 0&, lngSize, 0)
  117.     '
  118.     If lngRetVal = ERROR_NOT_SUPPORTED Then
  119.         '
  120.         'This API works only on Win 98/2000 and NT4 with SP4
  121.         MsgBox "IP Helper is not supported by this system."
  122.         Exit Function
  123.         '
  124.     End If
  125.     '
  126.     'Prepare the buffer
  127.     ReDim arrBuffer(0 To lngSize - 1) As Byte
  128.     '
  129.     'And call the function one more time
  130.     lngRetVal = GetIfTable(arrBuffer(0), lngSize, 0)
  131.     '
  132.     If lngRetVal = ERROR_SUCCESS Then
  133.         '
  134.         'The first 4 bytes (the Long value) contain the quantity of the table rows
  135.         'Get that value into the lngRows variable
  136.         CopyMemory lngRows, arrBuffer(0), 4
  137.         '
  138.         For i = 1 To lngRows
  139.             '
  140.             'Copy the table row data to the IfRowTable structure
  141.             CopyMemory IfRowTable, arrBuffer(4 + (i - 1) * Len(IfRowTable)), Len(IfRowTable)
  142.             '
  143.             With IfRowTable
  144.                 '
  145.                 objInterface.InterfaceDescription = Left(StrConv(.bDescr, vbUnicode), .dwDescrLen)
  146.                 '
  147.                 If .dwPhysAddrLen > 0 Then
  148.                     For j = 0 To .dwPhysAddrLen - 1
  149.                         objInterface.AdapterAddress = objInterface.AdapterAddress & _
  150.                                                   CStr(IIf(.bPhysAddr(j) = 0, "00", Hex(.bPhysAddr(j)))) & "-"
  151.                         '
  152.                     Next j
  153.                 objInterface.AdapterAddress = Left(objInterface.AdapterAddress, Len(objInterface.AdapterAddress) - 1)
  154.                    
  155.                 End If
  156.                 '
  157.                 objInterface.AdminStatus = .dwAdminStatus
  158.                 objInterface.InterfaceIndex = .dwIndex
  159.                 objInterface.DiscardedIncomingPackets = .dwInDiscards
  160.                 objInterface.IncomingErrors = .dwInErrors
  161.                 objInterface.NonunicastPacketsReceived = .dwInNUcastPkts
  162.                 objInterface.OctetsReceived = .dwInOctets
  163.                 objInterface.UnicastPacketsReceived = .dwInUcastPkts
  164.                 objInterface.UnknownProtocolPackets = .dwInUnknownProtos
  165.                 objInterface.LastChange = Len(.dwLastChange)
  166.                 objInterface.MaximumTransmissionUnit = .dwMtu
  167.                 objInterface.OperationalStatus = .dwOperStatus
  168.                 objInterface.DiscardedOutgoingPackets = .dwOutDiscards
  169.                 objInterface.OutgoingErrors = .dwOutErrors
  170.                 objInterface.NonunicastPacketsSent = .dwOutNUcastPkts
  171.                 objInterface.OctetsSent = .dwOutOctets
  172.                 objInterface.OutputQueueLength = .dwOutQLen
  173.                 objInterface.UnicastPacketsSent = .dwOutUcastPkts
  174.                 objInterface.Speed = .dwSpeed
  175.                 objInterface.InterfaceType = .dwType
  176.                 objInterface.InterfaceName = StrConv(.wszName, vbUnicode)
  177.                 '
  178.                 'Collect traffic info for all the interfaces
  179.                 '
  180.                 m_lngBytesReceived = m_lngBytesReceived + .dwInOctets
  181.                 m_lngBytesSent = m_lngBytesSent + .dwOutOctets
  182.                 '
  183.             End With
  184.             '
  185.             mvarInterfaces.Add objInterface
  186.             '
  187.         Next i
  188.         '
  189.     End If
  190.     '
  191. End Function

This is a class module. when I run my project it says

about this line:
VB Code:
  1. Public Property Set CInterfaces(ByVal vData As CInterfaces

that

User Defined type not defined
What can I do?

Shak