I'm trying to create a tool for users on our network to report their PC hostnames and IP addresses to the IT department. For assistance, we have a warehouse department that loves to shuffle around PCs and users, so I can't reliably tell who's on what PC. This is intended to be a quick way to stop them from saying "Jim's PC" and get them to give me useful information like "WAREHOUSE_WINXP_4".
I've created what I think should be a working program, and while it compiles and executes without errors, I can't seem to get the text box contents to set properly. The program is super-simple--just a form with 2 text boxes.
(Note: I'm more of a sysadmin/netadmin/infosec specialist, so I'm probably making some id10t mistakes here, but I'm kinda out of ideas on my own.)
Public Class Form1
Dim strHostname As String
Dim strIPAddress As String
Public Sub getHostname()
strHostname = System.Net.Dns.GetHostName()
'txtHostname.Text = strHostname Apparently putting it here won't work. In Load() maybe?
End Sub
Public Sub getIPAddress()
strIPAddress = System.Net.Dns.GetHostEntry(strHostname).AddressList(0).ToString()
'txtIPAddress.Text = strIPAddress Apparently putting it here won't work. In Load() maybe?
End Sub
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
getIPAddress()
getHostname()
txtHostname.Text = strHostname
txtIPAddress.Text = strIPAddress
End Sub
End Class