Create a folder using input from a text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kevint
    New Member
    • Nov 2006
    • 1

    Create a folder using input from a text box

    I am trying to create a folder based on inputed text from a text box. I can create the folder without a problem, it is when I add the text box in the mix I am having issues. Can someone please help?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by kevint
    I am trying to create a folder based on inputed text from a text box. I can create the folder without a problem, it is when I add the text box in the mix I am having issues. Can someone please help?
    I just created a new project, threw a textbox and a command button on a form, and inserted this code. It worked.
    Code:
    Private Sub Command1_Click()
      MkDir Text1.Text
    End Sub

    Comment

    • Pramodraya
      New Member
      • Jun 2007
      • 6

      #3
      Private Sub Command1_Click( )
      MkDir Text1.Text
      End Sub

      Hi,
      Using the above code, I could be able to create a directory, I need to give path also in the above syntax. can you please help in this regard.

      Regards,
      P.P.Kumar

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by Pramodraya
        ...I need to give path also in the above syntax. can you please help in this regard.
        Just concatenate the strings together. For example, to create folders under C:\Temp, you'd do something like this...
        [CODE=vb]Private Sub Command1_Click( )
        MkDir "C:\Temp\" & Text1.Text
        End Sub[/CODE]

        Comment

        • Pramodraya
          New Member
          • Jun 2007
          • 6

          #5
          With the above syntax, it not creating folder in the said path "c:\Temp\"
          Instead, it is creating folder with name "Text1.Text " on the current drive.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by Pramodraya
            With the above syntax, it not creating folder in the said path "c:\Temp\"
            Instead, it is creating folder with name "Text1.Text " on the current drive.
            Nonsense !

            For that to happen you'd have to have quotes in the wrong place. Unless, of course, the textbox called Text1 actually has the value "Text1.Text " in it. Um... no, not even then.

            Comment

            • Pramodraya
              New Member
              • Jun 2007
              • 6

              #7
              Hi,

              Please chack the below syntax again. It is not working for me.

              Private Sub Command1_Click( )
              MkDir "C:\Temp\" & Text1.Text
              End Sub

              I have placed quotes in correct place, and there is no value as such "Text1.Text "
              but with the above syntax it is creating folder "Text1.Text " in the current directory. Please check above syntax in your system.

              Regards,
              Pramod

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Ok...

                I created a new project, with one form. Placed a textbox (Text1) and command button (Command1) on the form. Copied/pasted in the code from your message. Ran. Entered "gkjghsklhg " in the text box, clicked the button. It created folder "C:\Temp\gkjghs klhg".

                Perhaps the folder is just left over from before? Or perhaps you have some old code that you haven't removed from your program, which is doing this. But the code as shown here will not create it.

                Comment

                • Pramodraya
                  New Member
                  • Jun 2007
                  • 6

                  #9
                  Hi Killer42,

                  Please give me a solution in 'visual basic 2005' for which, I need to move 3 files "a, b, c" from different locations to a folder ā€˜P’. The folder ā€˜P’ which is to be created using input from text box. Does concatenation of strings work with move command?

                  Thanks & Regards,
                  Pramod

                  Comment

                  • Killer42
                    Recognized Expert Expert
                    • Oct 2006
                    • 8429

                    #10
                    Originally posted by Pramodraya
                    Please give me a solution in 'visual basic 2005' for which, I need to move 3 files "a, b, c" from different locations to a folder ā€˜P’. The folder ā€˜P’ which is to be created using input from text box.
                    I can't provide VB 2005 code, as I only work with Vb6. I plan to start learning the later version soon, but that's no help to you.

                    Hopefully someone else here can do so, but I believe you should spend some time reading the doco, as creating a folder is a pretty basic (no pun intended) operation. One thing which might be a good idea is to use the FileSystemObjec t object. This provides lots of great functionality for working with drives, folders and files. Just note that to use it, you have to add a reference to "Microsoft Scripting Runtime" to your project.

                    Originally posted by Pramodraya
                    Does concatenation of strings work with move command?
                    That's a much easier question. It doesn't matter what command or statement you're dealing with. When you deal with a "string" in VB, generally this can be absolutely any expression which resolves to a string. It doesn't matter whether this means concatenating strings, invoking functions, or whatever. The string "ABC" is functionally no different from the string Chr(65) & Chr(Asc("B")) & "C".

                    Comment

                    • Pramodraya
                      New Member
                      • Jun 2007
                      • 6

                      #11
                      Hi Killer,
                      In the below VB code I want to input "password" in encripted format using InputBox, please help me in this regard

                      [CODE=vb]Dim Pwd As String = String.Empty
                      Dim Obj As Object
                      Pwd = InputBox("Enter the password", "Security")
                      If Pwd = "Password" Then
                      Dim oSettings As New Settings
                      oSettings.ShowD ialog()
                      LoadXml()
                      ElseIf Pwd = "" Then
                      Else
                      MessageCall("In avalid password", MessageBoxButto ns.OK)
                      End If[/CODE]
                      Last edited by Killer42; Aug 4 '07, 12:49 AM. Reason: Added [CODE=vb] tag

                      Comment

                      • hariharanmca
                        Top Contributor
                        • Dec 2006
                        • 1977

                        #12
                        Originally posted by Pramodraya
                        Hi Killer,
                        In the below VB code I want to input "password" in encripted format using InputBox, please help me in this regard


                        Code: ( vb )
                        Dim Pwd As String = String.Empty
                        Dim Obj As Object
                        Pwd = InputBox("Enter the password", "Security")
                        If Pwd = "Password" Then
                        Dim oSettings As New Settings
                        oSettings.ShowD ialog()
                        LoadXml()
                        ElseIf Pwd = "" Then
                        Else
                        MessageCall("In avalid password", MessageBoxButto ns.OK)
                        End If
                        why don't you use a different forum for that?
                        it will make your UI good.
                        Originally posted by Pramodraya
                        With the above syntax, it not creating folder in the said path "c:\Temp\"
                        Instead, it is creating folder with name "Text1.Text " on the current drive.
                        (LOL........bef ore posting you have to post your Req. Versions.)

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          Originally posted by hariharanmca
                          why don't you use a different forum for that?
                          it will make your UI good.
                          A different forum? This is VB-related, so what's the problem?

                          Comment

                          • Killer42
                            Recognized Expert Expert
                            • Oct 2006
                            • 8429

                            #14
                            Originally posted by hariharanmca
                            (LOL........bef ore posting you have to post your Req. Versions.)
                            The OP said (or at least implied) in post #9 that they use VB 2005.

                            Comment

                            • Killer42
                              Recognized Expert Expert
                              • Oct 2006
                              • 8429

                              #15
                              Originally posted by Pramodraya
                              ... In the below VB code I want to input "password" in encripted format using InputBox ...
                              Keep in mind that I'm only familiar with VB6, which is much older than your version. But as far as I'm aware, the InputBox function doesn't provide any way to "encrypt" input. I'm assuming that what you actually want is to mask the password on-screen, so others can't look over your shoulder and see what you've typed.

                              InputBox is really just a "quick and dirty" way to grab some text. I would only recommend using it during development as a shortcut. In a finished application you should develop your own user interface. The simplest way to do so in this case would be to stick a textbox and a couple of buttons on a form, put a bit of logic in there to handle the buttons, then show that modally (in VB 2005 I think that's done by ShowDialog).

                              Because it's "modal", control doesn't return to the calling code until the form is hidden or unloaded. So you can call it here in place of your InputBox and still use the same logic.

                              Comment

                              Working...