Default text in textboxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have done this once but don't remember how. The licensee appears in all new
textboxes as a default and it can be prevented from appearing, which I would
very much like to know how.
Can anyone help me with this?
Thanks
 
You can use an API call to get the username:

Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
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 = ""
End If
End Function

'not quite a textbox, but you can use it kind of like this:
Sub testme()
Dim resp As String
resp = InputBox(prompt:="Hi there", Default:=fOSUserName)
MsgBox resp
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top