Daily Archives: November 29, 2020

VB.NET || How To Get The Computer & User Client IP Address Using VB.NET

The following is a module with functions which demonstrates how to get the computers and user client request IPv4 IP address using VB.NET.

The function demonstrated on this page returns the IPv4 address of the calling user. When under a web environment, it returns the clients System.Web.HttpContext.Current.Request IP address, otherwise it returns the IP address of the local machine (i.e: server) if there is no request.

The following function uses System.Web to determine the IP address of the client.

Note: To use the function in this module, make sure you have a reference to ‘System.Web‘ in your project.

One way to do this is, in your Solution Explorer (where all the files are shown with your project), right click the ‘References‘ folder, click ‘Add Reference‘, then type ‘System.Web‘ in the search box, and add the reference titled System.Web in the results Tab.


1. Get IP Address

The example below demonstrates the use of ‘Utils.GetIPv4Address‘ to get the IPv4 address of the calling user.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

VB.NET || How To Copy DataTable DataRow From One DataRow To Another Using VB.NET

The following is a module with functions which demonstrates how to copy a DataTable DataRow from one DataRow to another using VB.NET.

The function demonstrated on this page is an extension method, which copies all matching columns from the source DataRow to the destination DataRow. If no matching column exists between the two rows, the data at that column is skipped. This allows to safely copy a single row from one DataTable to other.


1. Copy DataRow

The example below demonstrates the use of ‘Utils.Collections.CopyTo‘ to copy all matching columns from a source row to a destination row.


2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.