Click here to Skip to main content
15,881,938 members

Comments by nlarson11 (Top 3 by date)

nlarson11 28-Nov-11 16:21pm View    
Deleted
sorry typoed public function not private.
nlarson11 28-Nov-11 16:20pm View    
Deleted
you need to turn "option infer" on in your project properties this is from the exact code I use in my projects so I does work.

Imports System.Text.RegularExpressions
Imports System.Net

Public Class ComputerState
Private Function GetMachineIP(ByVal MachineName As String) As String
Const IPPattern As String = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"

Try
With Dns.GetHostEntry(MachineName)
Return .AddressList.Where(Function(a) Regex.IsMatch(a.ToString, IPPattern)).First.ToString
End With
Catch ex As Exception '* eat all exceptions - use "" as value
'RFState.ExceptionManager.LogActivity("Unable to resolve computer's IP address:" & ex.ToString)
Return String.Empty
End Try
End Function
End Class
nlarson11 21-Nov-11 17:39pm View    
Deleted
The IPPattern variable is a regular expression looking for 255.255.255.255 pattern

The “with” is a shortcut for property and method access of the object being “withed”.
So instead of typing
Textbox1.text = “”
Textbox1.tag = “”

You would type with infront
With textbox1
.text = “”
.tag = “”
End with

The return line is using linq looking for a regular expression match in all the instances of addresslist
Once found, it returns the first one that matches (.first) instead of going through all the matches.

Hope this helps.
Nathan