'Add the microsoft windows command controls and drop a statusbar to the form
'Paste the following code into the code section of the form.
Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
Dim sUser As String
Dim sComputer As String
Dim lpBuff As String * 1024
StatusBar1.Panels.Add
StatusBar1.Panels(1).AutoSize = sbrSpring
StatusBar1.Panels(2).Alignment = sbrRight
StatusBar1.Panels(1).Style = sbrDate
'Get the Login User Name
GetUserName lpBuff, Len(lpBuff)
sUser = Left$(lpBuff, (InStr(1, lpBuff, vbNullChar)) - 1)
lpBuff = ""
'Get the Computer Name
GetComputerName lpBuff, Len(lpBuff)
sComputer = Left$(lpBuff, (InStr(1, lpBuff, vbNullChar)) - 1)
lpBuff = ""
StatusBar1.Panels(2).Text = sComputer & " : " & sUser
End Sub
---------------------------------------------------
Some of this code was copied from faq222-429 Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'