Public Function GetMyComputerName() As String
Dim Bufstr$, sComputerName$
Bufstr = Space$(50)
If GetComputerName(Bufstr, 50) > 0 Then
sComputerName = Bufstr
sComputerName = RTrim(sComputerName)
sComputerName = StrStripTerminator(sComputerName)
Else
sComputerName = ""
End If
GetMyComputerName = sComputerName
End Function
Function StrStripTerminator(ByVal AString As String) As String
Dim intZeroPos As Integer
intZeroPos = InStr(AString, Chr$(0))
If intZeroPos > 0 Then
StrStripTerminator = Left$(AString, intZeroPos - 1)
Else
StrStripTerminator = AString
End If
End Function
Private Sub Form_Load()
MsgBox GetMyComputerName
End Sub