|
-
Jun 6th, 2006, 11:24 PM
#1
Thread Starter
Fanatic Member
Problem in appending string into variable
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!
VB Code:
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'.
-
Jun 7th, 2006, 12:09 AM
#2
Fanatic Member
Re: Problem in appending string into variable
It's there if you use the following:
But it doesn't show up with MsgBox for some reason. Strange.
-
Jun 7th, 2006, 12:34 AM
#3
Thread Starter
Fanatic Member
Re: Problem in appending string into variable
NO, even if I stored it into a variable and manipulate that variable it still give me the same problem.
-
Jun 7th, 2006, 01:55 AM
#4
Re: Problem in appending string into variable
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|