15,907,149 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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