0

Hello there!

This forums has helped me a lot to learn programming now I need your help again. I'm try to figure out a way to create a folder based on users input in Textbox on desktop.

Public Class Form1

    Dim username As TextBox

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim USERPROFILE As String
        USERPROFILE = Environ("HOMEPATH")
        Dim oShell : oShell = CreateObject("WScript.shell")
        IO.Directory.CreateDirectory(USERPROFILE & "\Desktop\"username)
    End Sub
End Class

It giving me errors. Can someone correct me and give a sample code for this?

Any help in appreciated.

3
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by Captain_Jack
0

Nothing actually. It's not even compiling. Error at this line IO.Directory.CreateDirectory(USERPROFILE & "\Desktop\"username)

1

You need a symbol to concatenate the "\Desktop\" and username. Also, you should be referencing the Text property of the TextBox username, not the TextBox itself.

Votes + Comments
Thanks
1
IO.Directory.CreateDirectory(USERPROFILE & "\Desktop\"username) 

I see an error. There is no & between "\Desktop\" and username

IO.Directory.CreateDirectory(USERPROFILE & "\Desktop\" & username)

You should also place all the calls outsite that event handler. You will be taking a memory hit. The event will fire everytime the text changes. So, as you type a directory, it will be creating a directory for every typed character.

Example:

MyDirectory typed in will create these directories:
M
My
MYD
MYDi
...

Edited by Maligui

Votes + Comments
Thanks
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.