Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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
  • 33,101 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
  • 33,101 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
  • 33,101 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
  • 33,101 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
  • 33,101 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
  • 33,101 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
  • 33,101 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