Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying current log user in VB form? 1

Status
Not open for further replies.

surad

Technical User
Mar 10, 2003
37
US
How can I display the current log user on a visual basic form.

Thanks
 
This may help
Dont know about VB, but in vba in excel, add a module and put the code below in. Then in any cell on your spreadsheet you can put =getuser()
Hope this helps.

Function GetUser()
GetUser = Environ("Username")
End Function

 
Hi
It's the same in VB/VBA just add the code to point to an object on the form and put the code into the initialize event, for example.

eg
Code:
Private Sub UserForm_Initialize()
Me.Caption = Environ("Username")
Me.Label1 = Environ("Username")
Me.TextBox1 = Environ("Username")
End Sub

xlbo has a FAQ showing how you can create a list of the available Environment variables. Alternatively you can use the SET command in a DOS window.

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top