VB.NET example

Nov 21, 2014 at 10:14 AM
New to UPNP, C# is alien to me, am used to working with VB.NET, suits me for creating simple desktop applications for home automation.
Been looking to incorporate SONOS audio component control in my applications.
Need simple vb example to discover SONOS devices and services.

Thanks
Coordinator
Nov 26, 2014 at 8:23 AM
Edited Nov 26, 2014 at 8:23 AM
Dear Alain1965,

I just used a C# to VB.NET converter on one of my examples, I havent tested it, but it gave this:
Public Sub DiscoveryExample()
    mdDiscovery = New Discovery(Nothing)
    ldDiscovery.DeviceAdded += New DeviceAddedEventHandler(AddressOf mdDiscovery_DeviceAdded)
    ldDiscovery.DeviceRemoved += New DeviceRemovedEventHandler(AddressOf mdDiscovery_DeviceRemoved)
    ldDiscovery.SearchComplete += New SearchCompleteEventHandler(AddressOf mdDiscovery_SearchComplete)

    ldDiscovery.Start()
End Sub

Private Sub mdDiscovery_SearchComplete(sender As Object, a As SearchCompleteEventArgs)
    ' NOTE: Event handler is not running in GUI thread
    Console.WriteLine("Initial Search complete, scanning for new devices.")
End Sub

Private Sub mdDiscovery_DeviceRemoved(sender As Object, a As DeviceRemovedEventArgs)
    ' NOTE: Event handler is not running in GUI thread
    Console.WriteLine(String.Format("Device Removed: {0}", a.UDN))
End Sub

Private Sub mdDiscovery_DeviceAdded(sender As Object, a As DeviceAddedEventArgs)
    ' NOTE: Event handler is not running in GUI thread
    Console.WriteLine(String.Format("Device Added: {0}", a.Device.ToString()))
End Sub
I cannot give you a SONOS example as I do not have one.

Thanks.