📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents mFile As System.Windows.Forms.MenuItem
Friend WithEvents mHelp As System.Windows.Forms.MenuItem
Friend WithEvents mAbout As System.Windows.Forms.MenuItem
Friend WithEvents mUrlToIp As System.Windows.Forms.MenuItem
Friend WithEvents mIpToUrl As System.Windows.Forms.MenuItem
Friend WithEvents mBlank As System.Windows.Forms.MenuItem
Friend WithEvents mExit As System.Windows.Forms.MenuItem
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents dialip As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents localdns As System.Windows.Forms.Label
Friend WithEvents localip As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
'Required by the Windows Form Designer
Private components As System.ComponentModel.Container
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.mIpToUrl = New System.Windows.Forms.MenuItem()
Me.mHelp = New System.Windows.Forms.MenuItem()
Me.mAbout = New System.Windows.Forms.MenuItem()
Me.Label1 = New System.Windows.Forms.Label()
Me.mUrlToIp = New System.Windows.Forms.MenuItem()
Me.Label3 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.dialip = New System.Windows.Forms.Label()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.localdns = New System.Windows.Forms.Label()
Me.localip = New System.Windows.Forms.Label()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.mBlank = New System.Windows.Forms.MenuItem()
Me.MainMenu1 = New System.Windows.Forms.MainMenu()
Me.mFile = New System.Windows.Forms.MenuItem()
Me.mExit = New System.Windows.Forms.MenuItem()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 80)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(100, 16)
Me.Label4.TabIndex = 5
Me.Label4.Text = "本机名称:"
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(16, 128)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(100, 16)
Me.Label5.TabIndex = 8
Me.Label5.Text = "拨号地址:"
'
'mIpToUrl
'
Me.mIpToUrl.Index = 1
Me.mIpToUrl.Shortcut = System.Windows.Forms.Shortcut.CtrlI
Me.mIpToUrl.Text = "IP地址->域名(&I)"
'
'mHelp
'
Me.mHelp.Index = 1
Me.mHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mAbout})
Me.mHelp.Shortcut = System.Windows.Forms.Shortcut.CtrlH
Me.mHelp.ShowShortcut = False
Me.mHelp.Text = "帮助(&H)"
'
'mAbout
'
Me.mAbout.Index = 0
Me.mAbout.Shortcut = System.Windows.Forms.Shortcut.CtrlA
Me.mAbout.Text = "关于域名与IP地址之间的转换(&A)..."
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(64, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "域名:"
'
'mUrlToIp
'
Me.mUrlToIp.Index = 0
Me.mUrlToIp.Shortcut = System.Windows.Forms.Shortcut.CtrlU
Me.mUrlToIp.Text = "域名->IP地址(&D)"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 104)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(100, 16)
Me.Label3.TabIndex = 4
Me.Label3.Text = "本机IP地址:"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(240, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(96, 24)
Me.Button1.TabIndex = 2
Me.Button1.Text = "域名->IP地址"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(240, 40)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(96, 24)
Me.Button2.TabIndex = 3
Me.Button2.Text = "IP地址->域名"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(280, 168)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 11
Me.Button3.Text = "退出(&X)"
'
'dialip
'
Me.dialip.ForeColor = System.Drawing.Color.Blue
Me.dialip.Location = New System.Drawing.Point(128, 128)
Me.dialip.Name = "dialip"
Me.dialip.Size = New System.Drawing.Size(120, 16)
Me.dialip.TabIndex = 9
Me.dialip.Text = "dialip"
'
'Panel1
'
Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1, Me.Label4, Me.Label5, Me.dialip, Me.Label1, Me.Label2, Me.Label3, Me.Button2, Me.localdns, Me.localip, Me.TextBox2, Me.Button1})
Me.Panel1.Location = New System.Drawing.Point(8, 8)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(344, 152)
Me.Panel1.TabIndex = 10
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(80, 8)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(140, 21)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(64, 16)
Me.Label2.TabIndex = 0
Me.Label2.Text = "IP地址:"
'
'localdns
'
Me.localdns.ForeColor = System.Drawing.Color.Blue
Me.localdns.Location = New System.Drawing.Point(128, 80)
Me.localdns.Name = "localdns"
Me.localdns.Size = New System.Drawing.Size(120, 16)
Me.localdns.TabIndex = 6
Me.localdns.Text = "localdns"
'
'localip
'
Me.localip.ForeColor = System.Drawing.Color.Blue
Me.localip.Location = New System.Drawing.Point(128, 104)
Me.localip.Name = "localip"
Me.localip.Size = New System.Drawing.Size(120, 16)
Me.localip.TabIndex = 7
Me.localip.Text = "localip"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(80, 40)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(140, 21)
Me.TextBox2.TabIndex = 2
Me.TextBox2.Text = ""
'
'mBlank
'
Me.mBlank.Index = 2
Me.mBlank.Text = "-"
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mFile, Me.mHelp})
'
'mFile
'
Me.mFile.Index = 0
Me.mFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mUrlToIp, Me.mIpToUrl, Me.mBlank, Me.mExit})
Me.mFile.Shortcut = System.Windows.Forms.Shortcut.CtrlF
Me.mFile.ShowShortcut = False
Me.mFile.Text = "文件(&F)"
'
'mExit
'
Me.mExit.Index = 3
Me.mExit.Shortcut = System.Windows.Forms.Shortcut.CtrlX
Me.mExit.Text = "退出(&X)"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(360, 201)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button3, Me.Panel1})
Me.MaximizeBox = False
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "域名与IP地址之间的转换"
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
localdns.Text = System.Net.Dns.GetHostName()
'获取主机DNS
Dim addr1, addr2 As System.Net.IPAddress
addr1 =New System.Net.IPAddress(System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList(0).Address)
localip.Text = addr1.ToString
'获取本地IP地址
addr2 = New System.Net.IPAddress(System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList(1).Address)
dialip.Text = addr2.ToString
'获取拨号IP地址
End Sub
Private Sub subUrlToIp()
Dim hostInfo As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(TextBox1.Text)
MessageBox.Show(hostInfo.AddressList(0).ToString, "主机地址", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'从域名到IP地址的转换
End Sub
Private Sub subIpToUrl()
Dim myIP As System.Net.IPAddress = System.Net.IPAddress.Parse(TextBox2.Text)
Dim hostInfo As System.Net.IPHostEntry = System.Net.Dns.GetHostByAddress(myIP)
MessageBox.Show(hostInfo.HostName.ToString, "主机域名", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'从IP地址到域名的转换()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
subExit()
'调用关闭应用程序函数
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
subUrlToIp()
'调用从域名到IP地址的转换函数
End Sub
Private Sub mUrlToIp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mUrlToIp.Click
subUrlToIp()
'调用从域名到IP地址的转换函数
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
subIpToUrl()
'调用从IP地址到域名的转换函数
End Sub
Private Sub mIpToUrl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mIpToUrl.Click
subIpToUrl()
'调用从IP地址到域名的转换函数
End Sub
Private Sub subExit()
Application.Exit()
'关闭应用程序
End Sub
Private Sub mAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mAbout.Click
Dim fAbout As New formAbout()
fAbout.Show()
'打开“关于”窗口
End Sub
Private Sub mExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mExit.Click
subExit()
'调用关闭应用程序函数
End Sub
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -