VB.NET中怎样获取本机的IP地址?

reasonchan 2006-12-01 04:14:15
谢谢
...全文
370 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
KahnWinsock 2006-12-01
  • 打赏
  • 举报
回复
To reasonchan (锋)

2005下调试通过的
Private Function GetIPAddress() As String
Dim strIPAddress As String
Try
strIPAddress = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName).AddressList(0).ToString
Catch ex As Exception
Return String.Empty
End Try

Return strIPAddress
End Function

2003下调试通过的
Private Function GetIPAddress() As String
Dim strIPAddress As String
Try
strIPAddress = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName).AddressList(0).ToString
Catch ex As Exception
Return String.Empty
End Try

Return strIPAddress
End Function
VirtualDesktop 2006-12-01
  • 打赏
  • 举报
回复
Dim a As String = Net.Dns.GetHostName()
Dim b As System.Net.IPHostEntry
Dim c As String
b = Net.Dns.GetHostByName(a)
c = b.AddressList(0).ToString
MsgBox(c)
cghhhh 2006-12-01
  • 打赏
  • 举报
回复
Dim strHostName As String
Dim strIPAddress As String

strIPAddress = System.Net.Dns.Resolve(strHostName).AddressList(0).ToString()

MessageBox.Show(" IP Address: " & strIPAddress)
从不签到 2006-12-01
  • 打赏
  • 举报
回复
Dim a As String = Net.Dns.GetHostName()
Dim b As System.Net.IPHostEntry
Dim c As String
b = Net.Dns.GetHostByName(a)
c = b.AddressList(0).ToString
MsgBox(c)
xiaomaolover 2006-12-01
  • 打赏
  • 举报
回复

Request.UserHostAddress

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧