Query Method

Public Function Query() As Long

Summary

This method is used to detect all ETH32 devices on the local network segment and all of their available device information and configuration settings. Once this method returns, the configuration data for any devices that have been found will be available through the Result Property.

Parameters

This method does not have any parameters.

Return Value

This method returns the number devices that have been found.

Remarks

The number of devices that were found is returned by the method, but also remains available from the NumResults Property. When you are finished with the results, you may free the memory associated with the results using the Free Method. This is done automatically for you if the object is destroyed, or if you call the DiscoverIp Method or the Query Method again on the same object. Note that this means each Eth32Config object holds only one active set of results at one time.

As opposed to the DiscoverIp Method, which is only supported by devices with firmware 3.000 and greater, the Query Method detects all devices with all firmware versions. This method sends several queries out repeatedly in case any queries or responses are lost on the network. It also delays for a short while to listen for responses. Because of this, the DiscoverIp Method method will be faster if you are looking for a specific device, know its MAC address or serial number, and know it is running firmware v3.000 or greater.

Example
Private Sub example()
Dim devdetect As New Eth32Config
Dim i As Long

' Set up error handling for this routine
On Error GoTo myerror

' Set broadcast address - this line would not
' be necessary since 255.255.255.255 is the default anyway
devdetect.BroadcastAddressString = "255.255.255.255"

' Find all devices
devdetect.Query

If devdetect.NumResults = 0 Then
    MsgBox "No devices were found."
Else
    For i = 0 To (devdetect.NumResults - 1)
        MsgBox "Device found with IP address of: " & _
               devdetect.IpConvertToString(devdetect.Result(i).active_ip)
    Next
End If

Exit Sub
myerror:
Dim temp As New Eth32
MsgBox "ETH32 error: " & temp.ErrorString(Err.number)
End Sub
       
See Also

Result Property, NumResults Property, DiscoverIp Method, Free Method