473,395 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create a folder using input from a text box

1
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?
Nov 3 '06 #1
16 9255
Killer42
8,435 Expert 8TB
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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.   MkDir Text1.Text
  3. End Sub
  4.  
Nov 3 '06 #2
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
Jun 27 '07 #3
Killer42
8,435 Expert 8TB
...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...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.   MkDir "C:\Temp\" & Text1.Text
  3. End Sub
Jun 28 '07 #4
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.
Jun 28 '07 #5
Killer42
8,435 Expert 8TB
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.
Jun 28 '07 #6
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
Jun 28 '07 #7
Killer42
8,435 Expert 8TB
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\gkjghsklhg".

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.
Jun 28 '07 #8
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
Jul 2 '07 #9
Killer42
8,435 Expert 8TB
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 FileSystemObject 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.

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".
Jul 2 '07 #10
Hi Killer,
In the below VB code I want to input "password" in encripted format using InputBox, please help me in this regard

Expand|Select|Wrap|Line Numbers
  1. Dim Pwd As String = String.Empty
  2. Dim Obj As Object
  3. Pwd = InputBox("Enter the password", "Security")
  4. If Pwd = "Password" Then
  5.     Dim oSettings As New Settings
  6.     oSettings.ShowDialog()
  7.     LoadXml()
  8. ElseIf Pwd = "" Then
  9. Else
  10.     MessageCall("Inavalid password", MessageBoxButtons.OK)
  11. End If
Aug 3 '07 #11
hariharanmca
1,977 1GB
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.ShowDialog()
LoadXml()
ElseIf Pwd = "" Then
Else
MessageCall("Inavalid password", MessageBoxButtons.OK)
End If
why don't you use a different forum for that?
it will make your UI good.
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........before posting you have to post your Req. Versions.)
Aug 3 '07 #12
Killer42
8,435 Expert 8TB
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?
Aug 4 '07 #13
Killer42
8,435 Expert 8TB
(LOL........before posting you have to post your Req. Versions.)
The OP said (or at least implied) in post #9 that they use VB 2005.
Aug 4 '07 #14
Killer42
8,435 Expert 8TB
... 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.
Aug 4 '07 #15
simmo
2
I don't know if I am missing something as well but I too am not having any luck creating a new folder. Keep getting the following runtime error

"You can't reference a property or method for a control unless the control has the focus"

Any help.......
Aug 6 '07 #16
gieo
2
@Pramodraya
it works in me using vb 2005,

Imports System
Imports System.IO

Public Class Form1

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click


MkDir(TextBox1.Text)


End Sub
End Class
Jan 16 '09 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dave | last post by:
I have an application where I am providing the user the ability to select or create a folder on a domain, using SHBrowseForFolder. When the user selects/creates a folder on a remote computer, it...
2
by: DCount17 | last post by:
I'm new to .NET and C#. I need help in trying to do the following: I need to use a URI (or something else) that allows all users of the application to be able to access a directory and create a...
1
by: namanhvu | last post by:
Hi everyone, I'm trying to create a form where the radio button is automatically selected when the input text field beside it is clicked. I know I need to use "onClick" somewhere but I don't...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
3
by: yangtono | last post by:
Hi, I'm trying to create a function that allows me to append the character at input text and display them on the div tag below. But the screen shouldn't refresh, therefore I'm using AJAX. But I...
2
by: msr | last post by:
Dear all Can anyone help me I've written VB program to save Pid and date into ms-access database but i need to alter my program in a way when i enter pid and date then automatically folders...
2
by: Jeterdawg | last post by:
Hello, extreme newbie here... I am trying to create a drop-down menu (select input type), and based on which of the options the user selects (Yes or No), an input text box appears for the user to...
1
by: meenu_susi | last post by:
hello could u please send me the code for creating a folder in ftp server using vb script I have tried with the following code <script language="vbscript"> Set objFSO =...
1
by: jags | last post by:
HI All I was trying to create Document librray programatically in a Sharepoint Site and is not working for me.I was trying to implement this as an Event Handler. The aim of the code is to create...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.