There is an API function you can use. Here's a wrapper function for that API function.
VB Code:
  1. Private Declare Function GetComputerName _
  2.  Lib "kernel32.dll" Alias "GetComputerNameA" ( _
  3.  ByVal lpBuffer As String, _
  4.  ByRef nSize As Long) As Long
  5.  
  6. Public Function GetCompName() As String
  7.     Dim sBuff As String
  8.     Dim nLen As Long
  9.     nLen = 215 'probably to large buffer
  10.     sBuff = Space$(nLen + 1)
  11.     If GetComputerName(sBuff, nLen) Then
  12.         GetCompName = Left$(sBuff, nLen)
  13.     Else
  14.         sBuff = Space$(nLen)
  15.         Call GetComputerName(sBuff, nLen)
  16.         GetCompName = Left$(sBuff, nLen)
  17.     End If
  18. End Function