Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'This expects the the mac address as a string of hex numbers separated by dashes
'e.g. 4d-3f-2-F-3c-40
'The "magic packet" consists of six FF's followed by the six bytes of the mac address repeated 16 times
Dim dataSend((17 * 6) - 1) As Byte
Dim macAddr(5) As Byte
Dim s() As String = Split(TextBox1.Text, "-")
For i As Integer = 0 To 5
dataSend(i) = &HFF 'Six FF's at the front of the data
macAddr(i) = Convert.ToByte(s(i), 16) 'Cache the six bytes of the mac address
Next
For i = 1 To 16 'follow the six FF's with 16 copies of the mac address
Array.Copy(macAddr, 0, dataSend, i * 6, 6)
Next
Dim myUdpClient As UdpClient
myUdpClient = New UdpClient("192.168.2.255", 40311)
myUdpClient.Send(dataSend, dataSend.Length)
myUdpClient.Close()
End Sub