Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
' make sure that using System.Diagnostics; is included
Imports System.Diagnostics
' make sure that using System.Security.Principal; is included
Imports System.Security.Principal
' need namespace System.Net;
Imports System.Net
' need namespace System.IO;
Imports System.IO
' need namespace System.Net.Sockets;
Imports System.Net.Sockets
Public Class Form1
Public Sub New()
MyBase.New()
InitializeComponent()
listBox1.Items.Add(LocalIPAddress().ToString())
label2.Text = GetPublicIP().ToString()
End Sub
Public Function LocalIPAddress() As String
Dim host As IPHostEntry
Dim localIP As String = ""
host = Dns.GetHostEntry(Dns.GetHostName())
For Each ip As IPAddress In host.AddressList
If ip.AddressFamily = AddressFamily.InterNetwork Then
localIP = ip.ToString()
Exit For
End If
Next
Return localIP
End Function
Public Function GetPublicIP() As String
Dim direction As [String] = ""
Dim request As WebRequest = WebRequest.Create("http://checkip.dyndns.org/")
Using response As WebResponse = request.GetResponse()
Using stream As New StreamReader(response.GetResponseStream())
direction = stream.ReadToEnd()
End Using
End Using
'Search for the ip in the html
Dim first As Integer = direction.IndexOf("Address: ") + 9
Dim last As Integer = direction.LastIndexOf("</body>")
direction = direction.Substring(first, last - first)
Return direction
End Function
#Region "basic function for app"
Private Sub lblLink_Click_1(sender As Object, e As EventArgs) Handles lblLink.Click
Process.Start("www.vclexamples.com")
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
If (keyData = Keys.Escape) Then
Me.Close()
Return True
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
#End Region
End Class
Search thousands of free JavaScript snippets that you can quickly copy and paste into your web pages. Get free JavaScript tutorials, references, code, menus, calendars, popup windows, games, and much more.
Subscribe to:
Post Comments (Atom)
Top 3 UX Design Articles of 2024 to Remember
Based on most subscriptions ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ...
-
code.gs // 1. Enter sheet name where data is to be written below var SHEET_NAME = "Sheet1" ; // 2. Run > setup // // 3....
No comments:
Post a Comment