object required

jasn_78

Registered User.
Local time
Today, 23:53
Joined
Aug 1, 2001
Messages
214
hey guys i get an object required on set mac = for the below code

Private Sub txtSERIAL_GotFocus()

Dim oWMIService As Object
Dim oColAdapters As Object
Dim oObjAdapter As Object
Dim mac As String
Dim y As Double
Dim z As Integer


Set oWMIService = GetObject("winmgmts:" & "!\\.\root\cimv2")
Set oColAdapters = oWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each oObjAdapter In oColAdapters
Next

Set mac = oColAdapters

For y = 1 To Len(mac)

If IsNumeric(Mid(mac, y, 1)) Then
z = z & Mid(mac, y, 1)
End If


Next y

Me.txtSERIAL = y

Set oObjAdapter = Nothing
Set oColAdapters = Nothing
Set oWMIService = Nothing

End Sub

any suggestions?
 
Some notes...


Private Sub txtSERIAL_GotFocus()

Dim oWMIService As Object
Dim oColAdapters As Object
Dim oObjAdapter As Object
Dim mac As String <---- variable is a STRING
Dim y As Double
Dim z As Integer


Set oWMIService = GetObject("winmgmts:" & "!\\.\root\cimv2")
Set oColAdapters = oWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each oObjAdapter In oColAdapters
Next

Set mac = oColAdapters <---Drop the SET statement here (i.e. - "mac = oColAdapters") SET is for objects

For y = 1 To Len(mac)

If IsNumeric(Mid(mac, y, 1)) Then
z = z & Mid(mac, y, 1)
End If


Next y

Me.txtSERIAL = y

Set oObjAdapter = Nothing
Set oColAdapters = Nothing
Set oWMIService = Nothing

End Sub

any suggestions?
 
thanks for ur advice there adam

didnt know that bout strings
 
Not a problem. Good luck...

Think of the SET statement as something that needs to be associated with heavy things, like objects... strings are not heavy. :)
 

Users who are viewing this thread

Back
Top Bottom