none
HOMEWORK HELP RRS feed

  • Question

  • I know I've seen them but I don't remember how I came across it. How do I find a person to put together a program for me (quickly) if I give them a list of specifications? I know I've seen people say "I need someone to transfer X number of data into this excel spreadsheet. I'll give you $x.xx via paypal". I have a project my roommate and I are stuck on and I really need the core of it put together. It's pretty basic VB but I'm not a programmer by any means...could someone point me in the direction to find a place where I could get this done?

    Thanks alot in advanced!!!
    Sunday, April 27, 2008 7:59 PM

Answers

  • I do C# as well

     

    sorry, it should be end using, not end reader

     

     

    using reader as StreamReader("myfile.txt")

     

       while reader.Peek() > -1

     

          Dim readLine as String = reader.ReadLine()

          Dim stringSplit() as String = readLine.Split(new Char() {CChar(",")}, StringSplitOptions.RemoveEmptyEntries)

     

          for each currentString as String in stringSplit

     

             Me.listBox.Items.Add(currentString)

     

          next

     

       end while

     

       reader.Close()

     

    end using

     

    Sunday, April 27, 2008 9:43 PM
    Moderator
  •  

    missed out the "new" keyword

     

    Using reader as new StreamReader(sportFile)

                While reader.Peek() > -1
                    Dim readLine As String = reader.ReadLine()
                    Dim stringSplit() As String = readLine.Split(New Char() {CChar(",")}, StringSplitOptions.RemoveEmptyEntries)

                    For Each currentString As String In stringSplit
                        sportListBox.Items.Add(currentString)

                    Next

                End While

                reader.Close()
            End Using

     

    Sunday, April 27, 2008 10:33 PM
    Moderator

All replies

  •  

    well you need to learn the language and ask questions. no one will do the entire thing for you, since it is your module at school you need to come up with the solution yourself. Sure, we can guide you to specific things but not develop the solution for you.

     

    what have you actually done?

    Sunday, April 27, 2008 8:16 PM
    Moderator
  • we have alot of the program working... we have a text file that looks like this

    car, van, truck
    test, test
    boat, house

    I need to add them to a list box and mak it look like this

    car
    van
    truck
    test
    test
    boat
    house

    does that make sense?

    I need to read the first line until it gets to a comma than add it to a listbox than continue rinse and repeat

    Sunday, April 27, 2008 8:22 PM
  •  

    read the entire file into a string, then split the string into a string() array, then for each item in the string array, add item to listbox.

     

    Dim readString as String = String.Empty

     

    using reader as new StreamReader("file.txt")

     

       readString = reader.ReadToEnd()

       reader.Close()

     

    end using

     

    Dim splitString() as String = readString.Split(new Char { "," } )

     

    for each currentString in splitString

     

       Me.listBox1.Items.Add(currentString)

     

    next

    Sunday, April 27, 2008 8:27 PM
    Moderator
  • where is currentString Coming from?
    Sunday, April 27, 2008 8:34 PM
  • my apologies, keyboard playing up. currentString should be declared as string:

     

    Dim readString as String = String.Empty

     

    using reader as new StreamReader("file.txt")

     

       readString = reader.ReadToEnd()

       reader.Close()

     

    end using

     

    Dim splitString() as String = readString.Split(new Char { "," } )

     

    for each currentString as String in splitString

     

       Me.listBox1.Items.Add(currentString)

     

    next

     

    Sunday, April 27, 2008 8:37 PM
    Moderator
  • that makes alot more sense it is saying that splitString is not declared... and I am getting an error around the first brace

    Dim splitString() as String = readString.Split(new Char { "," } )
    Sunday, April 27, 2008 8:40 PM
  • char should be an array.... here we go again (I really need to get a new keyboard!)

     

     

    Dim readString as String = String.Empty

     

    using reader as new StreamReader("file.txt")

     

       readString = reader.ReadToEnd()

       reader.Close()

     

    end using

     

    Dim splitString() as String = readString.Split(new Char() { "," } )

     

    for each currentString as String in splitString

     

       Me.listBox1.Items.Add(currentString)

     

    next

     

    Sunday, April 27, 2008 8:42 PM
    Moderator
  • We have to have OptionStrict on and it says OptionStrict disallows conversion from string to Char...
    Sunday, April 27, 2008 8:45 PM
  • try this:

     

    Dim splitString() as String = readString.Split(new Char() { CChar(",") } )

     

     

    Sunday, April 27, 2008 8:50 PM
    Moderator
  • Awesome one more thing for now hahaha

    we are getting a wierd Character and it is not splitting the words when it has a return line
    Sunday, April 27, 2008 8:55 PM
  • try this....

     

    Dim readString as String = String.Empty

     

    using reader as new StreamReader("file.txt")

     

       readString = reader.ReadToEnd()

       reader.Close()

     

    end using

     

    Dim splitString() as String = readString.Split(new Char() { CChar(",") },  StringSplitOptions.RemoveEmptyEntries)

     

    for each currentString as String in splitString

     

       Me.listBox1.Items.Add(currentString)

     

    next

     

     

    Sunday, April 27, 2008 8:58 PM
    Moderator
  • http://nsyfa.org/jeremy/screenshot_code.bmp

    in between baseball and softball and rock climbing and golf
    Sunday, April 27, 2008 9:14 PM
  •  

    sure, because the listbox doesnt support newlines....

     

    you could also do this....

     

    using reader as StreamReader("myfile.txt")

     

       while reader.Peek() > -1

     

          Dim readLine as String = reader.ReadLine()

          Dim stringSplit() as String = readLine.Split(new Char() {CChar(",")}, StringSplitOptions.RemoveEmptyEntries)

     

          for each currentString as String in stringSplit

     

             Me.listBox.Items.Add(currentString)

     

          next

     

       end while

     

       reader.Close()

     

    end reader

     

    Sunday, April 27, 2008 9:25 PM
    Moderator
  • that makes sense read each line seperatly

    I am getting an Error at the USING and the end Reader... the using is saying that it needs an end

    (PS I do my coding in C# so alot of these errors make sense to me but i don't know VB syntax)
    Sunday, April 27, 2008 9:34 PM
  • I do C# as well

     

    sorry, it should be end using, not end reader

     

     

    using reader as StreamReader("myfile.txt")

     

       while reader.Peek() > -1

     

          Dim readLine as String = reader.ReadLine()

          Dim stringSplit() as String = readLine.Split(new Char() {CChar(",")}, StringSplitOptions.RemoveEmptyEntries)

     

          for each currentString as String in stringSplit

     

             Me.listBox.Items.Add(currentString)

     

          next

     

       end while

     

       reader.Close()

     

    end using

     

    Sunday, April 27, 2008 9:43 PM
    Moderator
  • Now I'm getting: "peek" and "readline" are not members of System.Array....
    Sunday, April 27, 2008 9:52 PM
  • please post the entire code snippet you are using in your code.

     

    Sunday, April 27, 2008 9:56 PM
    Moderator
  • Private sportFile As StreamReader        'allows user to read opened data file
        Private strInputString As String


        Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
            'This will open the file
            Dim responseDialogResult As System.Windows.Forms.DialogResult

            'Begin in the project folder
            OpenFileDialog1.InitialDirectory = Application.StartupPath

            responseDialogResult = OpenFileDialog1.ShowDialog
            If responseDialogResult <> System.Windows.Forms.DialogResult.Cancel Then
                sportFile = New StreamReader(OpenFileDialog1.FileName)

            End If


    Using reader as StreamReader(sportFile)

                While reader.Peek() > -1
                    Dim readLine As String = reader.ReadLine()
                    Dim stringSplit() As String = readLine.Split(New Char() {CChar(",")}, StringSplitOptions.RemoveEmptyEntries)

                    For Each currentString As String In stringSplit
                        sportListBox.Items.Add(currentString)

                    Next

                End While

                reader.Close()
            End Using

        End Sub
    Sunday, April 27, 2008 10:19 PM
  •  

    missed out the "new" keyword

     

    Using reader as new StreamReader(sportFile)

                While reader.Peek() > -1
                    Dim readLine As String = reader.ReadLine()
                    Dim stringSplit() As String = readLine.Split(New Char() {CChar(",")}, StringSplitOptions.RemoveEmptyEntries)

                    For Each currentString As String In stringSplit
                        sportListBox.Items.Add(currentString)

                    Next

                End While

                reader.Close()
            End Using

     

    Sunday, April 27, 2008 10:33 PM
    Moderator