Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Visual Basic Help


  • Please log in to reply

#1
equinox55

equinox55

    Member

  • Member
  • PipPipPip
  • 132 posts
Hello I am trying to build a program in visual basic that can take a list of 200 names (1st and last) and make a new folder for each name. The only problem is that I do ont know what "box" I should use. Like a text box or what, but with a text box i would be limited to adding just one name at a time and I want to copy the whole list and then hit a button to make the folders. Or would it be easier to load the list from a .txt file at run time and do it that way. Any help would be apperciated.


I also know Java and know how to do this in java but I really need a .exe and i dont know how to amke an .exe in Java (if that is even possible)


Davis
  • 0

Advertisements


#2
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,958 posts
Hi equinox55,

Do you want to learn from this or would you be satisfied with a ready solution?

I think I can fabricate something in VB.Net that you can drag & drop a list of names in a .txt file into the program window and that produces a set of folders by the same names in a specified directory.
The program would read the names separated by RETURNs and try to create the folder.

Should it check if a folder by that name already exists and if so, what should happen?
  • 0

#3
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
I would like to build it my self but just need a lttile help on how to be able to drag it and how the code to create the folders
  • 0

#4
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,958 posts
OK. If I post some snippets I have in VB.Net would that help you?
It's the only language I know well enough. :)
  • 0

#5
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,958 posts
The code to get the location and name of the txt file if you drop it in an area on the form:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		pb.AllowDrop = True
	End Sub

	Private Sub pb_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pb.DragDrop
		Dim filePaths As String()
		Try
			filePaths = CType(e.Data.GetData(DataFormats.FileDrop), String())
		Catch ex As Exception
			TextBox1.Text = ex.Message
			TextBox1.Text &= "Error Doing Drag/Drop"
		End Try
		For Each filename In filePaths
			TextBox1.Text &= filename & vbNewLine
		Next
	End Sub

	Private Sub pb_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pb.DragEnter
		If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
			e.Effect = DragDropEffects.Copy
		End If
	End Sub

Where it says:
TextBox1.Text &= filename & vbNewLine
would be the right place to trigger a streamreader that reads the list of names
  • 0

#6
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
Ok and what is the code to create a folder?
  • 0

#7
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
Oh and how do I separate the names in to 1st and last name and then sort them alphabetically by last name
  • 0

#8
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,958 posts

Ok and what is the code to create a folder?

Try
Directory.CreateDirectory("name and path of the folder")
Catch ex As Exception
			MsgBox = ex.Message
		End Try
End Try

  • 0

#9
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,958 posts

Oh and how do I separate the names in to 1st and last name and then sort them alphabetically by last name


How will the names in the text file be separated?
  • 0

#10
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
Thanks the names would be like
abby joe
bob sue
steve jobs
Oddy Fore
etc
  • 0

Advertisements


#11
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
Oh and how do i do the drag and drop in to what item on the form like a text box or what
  • 0

#12
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,958 posts

Thanks the names would be like
abby joe
bob sue
steve jobs
Oddy Fore
etc


OK, so first and last name separated by one space and the names by carriage returns?
And will there be names like Rip van Winkle, consisiting of three parts?
If so how would you want those separated?
  • 0

#13
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
Yes there may be some like that and some like amy-lee Jin Jan all one name but it has to sort by last name, and what container do i place on the form to drag and drop the names in to
  • 0

#14
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,958 posts

Oh and how do i do the drag and drop in to what item on the form like a text box or what


Handles pb.DragDrop

pb is a part of the form, a picturebox in this case.
  • 0

#15
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
ok i wll give this a try
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP