Edited by Tigger93, 16 June 2006 - 09:41 AM.
VB %userprofile% help
Started by
Tigger93
, Jun 16 2006 09:40 AM
#1
Posted 16 June 2006 - 09:40 AM
#2
Posted 16 June 2006 - 01:37 PM
Hey there Tigger93, I wrote up this little code for you that you can use.
Ok, all you have to do is add a text box and a command button. Make a text file in your documents called "testfile".
It will then delete the file in your documents called "testfile.txt".
Cool
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Private Sub Command1_Click() Kill "C:\Documents and Settings\" + Text1.Text + "\My Documents\testfile.txt" End Sub Private Sub Form_Load() Dim sBuffer As String Dim lSize As Long sBuffer = Space$(255) lSize = Len(sBuffer) Call GetUserName(sBuffer, lSize) If lSize > 0 Then Text1.Text = Left$(sBuffer, lSize) Else Text1.Text = vbNullString End If End Sub
Ok, all you have to do is add a text box and a command button. Make a text file in your documents called "testfile".
It will then delete the file in your documents called "testfile.txt".
Cool
#3
Posted 16 June 2006 - 01:43 PM
Thanks, but it says "Declare" is not a valid identifier. It also says Text1.Text is not delcared.
Edited by Tigger93, 16 June 2006 - 01:47 PM.
#4
Posted 16 June 2006 - 01:47 PM
Are you running VB6?
The top code must go into the declerations, this is above all the other coding right on top.
Also try and add the "Option Explicit" on the first line of code: EG
Let me know if it is still giving problems. Cool
Edit: And make sure you add a text box
The top code must go into the declerations, this is above all the other coding right on top.
Also try and add the "Option Explicit" on the first line of code: EG
Option Explicit Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long [Rest Of Code...]
Let me know if it is still giving problems. Cool
Edit: And make sure you add a text box
Edited by spike_hacker_inc, 16 June 2006 - 01:48 PM.
#5
Posted 16 June 2006 - 01:49 PM
Eh... My bad, here. I'm running VB 2005...
#6
Posted 16 June 2006 - 01:53 PM
Sorry Tigger93, I am not to suped up on VB2005. So I cant help any more than I have. I will look around for you though and try and pick up something.
Sorry, Cool
Sorry, Cool
#7
Posted 16 June 2006 - 01:54 PM
Thanks.
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users