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

#16
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
I get this error statement is not valid in a namespace
  • 0

Advertisements


#17
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
man this would be so much easier in java, But in java can you make a self contained exe
  • 0

#18
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
I have not worked with visual basic in about 2 years now
  • 0

#19
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
code you code it and then show me the code for it in visual basic
  • 0

#20
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 posts
You can download the exe that corresponds with the code below here:
http://metallica.gee...com/equinox.exe

Public Class equinox
	Public Function readfile(ByVal filename As String) As String
		Dim fs = New System.IO.StreamReader(filename)
		Dim complete As String = fs.ReadToEnd
		fs.close()
		TextBox1.Text &= complete
		Return complete
	End Function
	Public Function createfolders(ByVal complete As String) As Boolean
		Dim output As String = ""
		Dim ss1 As String = Chr(32)
		Dim ss2 As String = Chr(13)
		Dim moreoptions As Boolean = True
		Dim i As Integer = 1
		Dim j As Integer = 1
		Dim k As Integer = 1
		Dim lastname As String = ""
		Dim builder As New System.Text.StringBuilder("List of last names" & vbNewLine)
		If complete <> "" Then
			While moreoptions
				j = complete.IndexOf(ss1, i)
				If j <> -1 Then
					k = complete.IndexOf(ss2, j)
					If k <> -1 Then
						lastname = complete.Substring((j + 1), (k - j))
						Try
							System.IO.Directory.CreateDirectory("C:\testfolder\" & lastname)
						Catch ex As Exception
							MsgBox(ex.Message)
						End Try
						builder.Append(lastname & vbNewLine)
						i = k + 1
						j = k
					Else : moreoptions = False
					End If
				Else : moreoptions = False
				End If
			End While
			output = builder.ToString
		End If
		TextBox1.Text &= vbNewLine & builder.ToString
		Return output
	End Function
	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 filename As String
		Dim filePaths As String()
		Dim ender As String = "ready"
		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
			If createfolders(readfile(filename)) Then
				TextBox1.Text &= vbNewLine & ender
			End If
		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
End Class

It is a bit crude, but it does what you wanted and you should be able to adapt it to your specific wishes.
  • 0

#21
equinox55

equinox55

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 132 posts
I know this mayseem like a basic question but how when I click "create folders" button that it will ask where to make the folders (a browse box would be awsome) and then creat them
  • 0

#22
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 posts
I can make a textbox where you can input the folder in which the other will be created.
  • 0

#23
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 posts
Same downloadlink: http://metallica.gee...com/equinox.exe

The code I added was in the createfolders function. It now looks like this:

Public Function createfolders(ByVal complete As String) As Boolean
		Dim output As String = ""
		Dim ss1 As String = Chr(32)
		Dim ss2 As String = Chr(13)
		Dim moreoptions As Boolean = True
		Dim i As Integer = 1
		Dim j As Integer = 1
		Dim k As Integer = 1
		Dim lastname As String = ""
		Dim approot As String = "C:\testfolder\"
		If rootfolder.Text <> "" Then
			approot = rootfolder.Text & "\"
		End If
		Dim builder As New System.Text.StringBuilder("List of last names" & vbNewLine)
		If complete <> "" Then
			While moreoptions
				j = complete.IndexOf(ss1, i)
				If j <> -1 Then
					k = complete.IndexOf(ss2, j)
					If k <> -1 Then
						lastname = complete.Substring((j + 1), (k - j))
						Try
							System.IO.Directory.CreateDirectory(approot & lastname)
						Catch ex As Exception
							MsgBox(ex.Message)
						End Try
						builder.Append(lastname & vbNewLine)
						i = k + 1
						j = k
					Else : moreoptions = False
					End If
				Else : moreoptions = False
				End If
			End While
			output = builder.ToString
		End If
		TextBox1.Text &= vbNewLine & builder.ToString
		Return output
	End Function

  • 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