I use this Environ() array to return a PC name.
Code:Public Function GetComputerName() As String 'This Function will return the current PC's number Dim sEnvironmentString As String Dim Indx As Integer Indx = 1 ' Initialize index to 1. Do sEnvironmentString = Environ(Indx) ' Get environment If Left(sEnvString, 13) = "COMPUTERNAME=" Then ' Check PATH entry. GetComputerName = Right(sEnvironmentString, Len(sEnvironmentString) - 13) Exit Function Else Indx = Indx + 1 ' Not COMPUTERNAME entry, so increment End If Loop Until sEnvironmentString = "" GetComputerName = "(Unable to identify PC)" End Function




Reply With Quote