Re: Obtaining MAC Address
This would work. This code uses WMI calls to get the computer information. This section of code will get the mac address of the network card that is in use that the time.
Code:
Public Sub GetWMIAdapter()
Dim oAdapters As Object
Dim oAdapter As Object
On Error Resume Next
Set oAdapters = GetObject("winmgmts:").ExecQuery( _
"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each oAdapter In oAdapters
With oAdapter
Label1.Caption "MAC:" & vbTab & vbTab & .MACAddress
End With
Next
End Sub
Re: Obtaining MAC Address
Hi Wiccaan
Ive done this sujestion:
Code:
Private Sub Command1_Click()
Call GetWMIAdapter
End Sub
Public Sub GetWMIAdapter()
Dim oAdapters As Object
Dim oAdapter As Object
On Error Resume Next
Set oAdapters = GetObject("winmgmts:").ExecQuery( _
"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each oAdapter In oAdapters
With oAdapter
Label1.Caption "MAC:" & vbTab & vbTab & .MACAddress
End With
Next
End Sub
I get a compile error which says invalid use of property and highlights .caption
Im a noob to all this VB sorry if its a silly question
Re: Obtaining MAC Address
I think you need to change the line:
Label1.caption "MAC ...
to
Label1.caption = "MAC ...
Re: Obtaining MAC Address
As TheBoy pointed out... it was missing the '=' that was my fault. Sorry about that, but it should work.
Re: Obtaining MAC Address
Cheers guys, silly me, im a noob :D
Heres one for you wiccaan,
I need to write some code that can do a tracert www.yahoo.com (any url) and save the first Hop ip address.
Can this be done?
cheers
Re: Obtaining MAC Address
You could shellexecute tracert.exe passing the correct parameters and output to a textfile. Then read the file into your program.
Code:
tracert -d -h 1 > C:\OneHop.txt www.yahoo.com
Tracing route to www.yahoo.akadns.net [66.94.230.32]
over a maximum of 1 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
Trace complete.