changing vb to vb.net


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: changing vb to vb.net

  1. #1
    Join Date
    Apr 2005
    Posts
    47

    changing vb to vb.net

    Hi everyone,
    I'm pretty new to VB.net. I have vb code which parse some info and i want to change it to vb.net can anyone help me with this part of my code?
    Dim appbase As String = AppDomain.CurrentDomain.SetupInformation.ApplicationBase()
    For i = 0 To UBound(file_names)
    System.IO.File.OpenText (appbase & "\" & file_names(i)) For Input As #1

    Do While Not EOF#1
    Dim ALineIn = LineInput(1), temp
    Dim Delimiter As String
    file_data = ALineIn.Split(Delimiter, " ")
    file_data(j) = Trim$(temp)
    j = j + 1
    Loop

    Close()
    Next i
    i made some changes inorder to be in vb.net but still the "For Input As #1" and "#1" in while loop is not working. It simply reads files in a path and goes to next one. there are three files
    appreciate any help
    thanks
    Last edited by pantea; 04-12-2005 at 01:42 PM.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I don't understand what you're trying to do in the Do While Not EOF#1 loop?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2005
    Posts
    47
    go to directory and open 3 files. here is first part of my code:
    Dim file_names() As String = {"m1.txt", "m2.txt", "m3.txt"}
    i want to parse those and,
    For i = 0 To UBound(file_names)
    System.IO.File.OpenText((appbase & "\" & file_names(i)) For Input As #1

    Do While Not EOF(1)
    Dim ALineIn = LineInput(1), temp
    Dim Delimiter As String
    file_data = ALineIn.Split(Delimiter, " ")
    file_data(j) = Trim$(temp) j = j + 1
    Loop

    Close()
    Next i
    here i will go to directory and look for names and will parse the whole file
    seprate it into lines
    and split it by space

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Here's how I would write it:
    Code:
    Dim file_data() As String
    Dim file_names() As String = {"m1.txt", "m2.txt", "m3.txt"}
    Dim appbase As String = Application.StartupPath
    
    For Each file_name As String In file_names
        Dim reader As StreamReader = File.OpenText(appbase & "\" & file_name)
        Do
            Dim ALineIn As String = reader.ReadLine()
            If ALineIn Is Nothing Then Exit Do
            file_data = Split(ALineIn)
        Loop
        reader.Close()
    Next
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Apr 2005
    Posts
    47
    Thank you alot that solve the problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center