0

Rev. Jim / Minimalist, I'm attempting to convert the code to VB.net. I've got it to write something but it's writing only one line. I'm sure I need to use "Using" or some kind of loop for it to read and write each line. Here's what I've got so far:

            My.Computer.FileSystem.ReadAllText(RestranName)
            ' This begins to add the carriage returns in the appropriate places
            txtLine = Replace(Text, vbLf, vbCrLf)
            txtLine = Replace(Text, vbCr & vbCr, vbCr)
            txtLine = Replace(Text, """", "")

            ' This writes the line to the file
            My.Computer.FileSystem.WriteAllText(fileSave, txtLine, False)

I got an error message when I tried "Using". The line looked like this:

Using My.Computer.FileSystem.ReadAllText(RestranName)

The message said "Using operand of type "String" must implement "System.IDisposal". I'm not sure what it's trying to tell me.

Thought and ideas?

Thanks again.

Don

0

You don't need Using.

Dim text As String = My.Computer.FileSystem.ReadAllText(RestranName)

will read the entire file into one string variable.

0

Group,

I finally figured it out. Here's the final code:

        RestranName = "C:\Restran Conversion\IPSDATA\PM00213A\20141210.142601"
        Dim fileSave As String = "C:\Restran Conversion\IPSDATA\PM00213A\213RT20141210.txt"

        ' This reads the text file for conversion
        txtLine = My.Computer.FileSystem.ReadAllText(RestranName)
        ' This begins to add the carriage returns in the appropriate places
        txtLine = Replace(txtLine, vbLf, vbCrLf)
        txtLine = Replace(txtLine, vbCr & vbCr, vbCr)
        txtLine = Replace(txtLine, """", "")

        ' This writes the line to the file
        My.Computer.FileSystem.WriteAllText(fileSave, txtLine, False)

Again, thank you everyone for your help.

Don

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.