H
H. Martins
While trying for the first time to run a functioning 2003 code I got
into an error and I don't know what to do about it.
I pasted the following code into a module called General (where a
couple more general functions are located), adding a header like:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
The function is:
'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUsername As String
strUsername = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUsername, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUsername, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
I don't understand this code, I just pasted it.
Now I a getting the error:
"Can't find project or library."
.... apparently the compiler doesn't like "String$"
Can I have some help, please?
Thanks
Henry
into an error and I don't know what to do about it.
I pasted the following code into a module called General (where a
couple more general functions are located), adding a header like:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
The function is:
'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUsername As String
strUsername = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUsername, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUsername, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
I don't understand this code, I just pasted it.
Now I a getting the error:
"Can't find project or library."
.... apparently the compiler doesn't like "String$"
Can I have some help, please?
Thanks
Henry