>In Visual Fox, the function sys(0) will return the user's logon name. Is there a similar function available in Visual Basic? I hope I don't have to go into Win API just to get the user's name.
Yes, you need to go to the API to retrieve it, but you don't need as much code as Penmetsa wrote.
Try this simple code.
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim lngSize As Long
Dim strBuffer As String
strBuffer = Space$(255)
lngSize = Len(strBuffer)
Call GetUserName(strBuffer, lngSize)
If lngSize > 0 Then
MsgBox Left$(strBuffer, lngSize)
Else
MsgBox "Unknown user"
End If
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com