Please may someone let me know how I can get the computer's name in VB code.
Thanks
Printable View
Please may someone let me know how I can get the computer's name in VB code.
Thanks
In a module
option Explicit
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (byval lpBuffer as string, nSize as Long) as Long
In a form
option Explicit
private Sub Form_Load()
Dim sComputer as string
Dim lpBuff as string * 1024
'get the Computer Name
GetComputerName lpBuff, len(lpBuff)
sComputer = Left$(lpBuff, (InStr(1, lpBuff, vbNullChar)) - 1)
lpBuff = ""
MsgBox "Computer Name: " & sComputer
End
End Sub
David Paulson
Great. If the one who asked do not rate, I do.
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.