PDA

Click to See Complete Forum and Search --> : Problem in appending string into variable


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'.

VBAhack
Jun 7th, 2006, 12:09 AM
It's there if you use the following:

Debug.Print current_user

But it doesn't show up with MsgBox for some reason. Strange.

daimous
Jun 7th, 2006, 12:34 AM
NO, even if I stored it into a variable and manipulate that variable it still give me the same problem.

RobDog888
Jun 7th, 2006, 01:55 AM
Posted code solution here - http://vbforums.com/showpost.php?p=2499725&postcount=10