daimous
Jun 6th, 2006, 11:24 PM
hi! can anybody please help me with this..how can append a string into the current_user variable let say current_user = "daimous" then i want to append something after the current_user say "the great" so that i have "daimous the great" in the variable.. how can I do this? by the way, i've already tried current_user = current_user & " the great" but the "the great" string is always missing. i included my code below to give you a clear idea of what my problem is...hope you could help me with this..thanks a bunch!
Private Enum EXTENDED_NAME_FORMAT
NameUnknown = 0
NameFullyQualifiedDN = 1
NameSamCompatible = 2
NameDisplay = 3
NameUniqueId = 6
NameCanonical = 7
NameUserPrincipal = 8
NameCanonicalEx = 9
NameServicePrincipal = 10
End Enum
Private Declare Function GetUserNameEx Lib "secur32.dll" Alias _
"GetUserNameExA" (ByVal NameFormat As EXTENDED_NAME_FORMAT, _
ByVal lpNameBuffer As String, ByRef nSize As Long) As Long
Private Sub Command1_Click()
Dim sBuffer As String, Ret As Long
sBuffer = String(256, 0)
Ret = Len(sBuffer)
If GetUserNameEx(NameSamCompatible, sBuffer, Ret) <> 0 Then
current_user = Left$(sBuffer, Ret) & " the great"
Else
current_user = Environ("USERNAME") & " the great"
End If
msgbox current_user,vbOkOnly
End SUb
Output: ABS\Administrator
*Note: "the great" is missing.. I want the great to appear after 'ABS\Administrator'.
Private Enum EXTENDED_NAME_FORMAT
NameUnknown = 0
NameFullyQualifiedDN = 1
NameSamCompatible = 2
NameDisplay = 3
NameUniqueId = 6
NameCanonical = 7
NameUserPrincipal = 8
NameCanonicalEx = 9
NameServicePrincipal = 10
End Enum
Private Declare Function GetUserNameEx Lib "secur32.dll" Alias _
"GetUserNameExA" (ByVal NameFormat As EXTENDED_NAME_FORMAT, _
ByVal lpNameBuffer As String, ByRef nSize As Long) As Long
Private Sub Command1_Click()
Dim sBuffer As String, Ret As Long
sBuffer = String(256, 0)
Ret = Len(sBuffer)
If GetUserNameEx(NameSamCompatible, sBuffer, Ret) <> 0 Then
current_user = Left$(sBuffer, Ret) & " the great"
Else
current_user = Environ("USERNAME") & " the great"
End If
msgbox current_user,vbOkOnly
End SUb
Output: ABS\Administrator
*Note: "the great" is missing.. I want the great to appear after 'ABS\Administrator'.