Improve company productivity with a Business Account.Sign Up
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function WhoAmI(bReturnUserName As Boolean) As String
' Function returns either user name or computer name
Dim strName As String * 255
10 If bReturnUserName = True Then
20 GetUserNameA strName, Len(strName)
40 GetComputerNameA strName, Len(strName)
50 End If
60 WhoAmI = left$(strName, InStr(strName, vbNullChar) - 1)
Open in new window
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.