I have a module function that returns the Microsoft Network Username and Computername. I have tried calling it from a form Load but get the error: Compile error - Expected variable or procedure, not module. Why? Does this code need to be somewhere else?
Public Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long 'i.e. strUserNetworkName = MMC_WNetGetUser "", strUser, 255
Public Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal buffer As String, ByRef nsize As Long) As Boolean
Public Function GetUsernameComputerName(strUserName As String, strHost As String)
Const MAXCHAR As Integer = 50 'Max. no. of chars. in computer name
'Dim strHost As String 'Name of computer returned by function
'Dim strUserName As String 'Network Name of User
'*****************************
'* Get User's Network Name *
'*****************************
Public UserName, HostName
Public Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long 'i.e. strUserNetworkName = MMC_WNetGetUser "", strUser, 255
Public Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal buffer As String, ByRef nsize As Long) As Boolean
Public Function GetUsernameComputerName()
Const MAXCHAR As Integer = 50 'Max. no. of chars. in computer name
Dim strHost As String 'Name of computer returned by function
Dim strUserName As String 'Network Name of User
'*****************************
'* Get User's Network Name *
'*****************************
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.