Reading pieces of text from a file

Dr Obvious

New member
Joined
Oct 26, 2003
Messages
2
Another fun little question. We figured out how to get the text written to a file on the form of something like this:

>Line-file 1: filename-l1
>Line-file 2: filename-l2
>...
>Line-file 3: filename-ln

where n is the number of line files and filename-ln is the name of a specific line file (a .tiff file). We need to know how to make VB read just the filename-ln but we cant seem to find the right command to do this. Does anybody know anything about this?

Thanks,
Tommy
 
Try something like
Code:
Dim my As IO.StreamReader
        my = IO.File.OpenText("A:\Your TextFile.txt")
        
        Dim fmtStr As String = "{0,11}{1,4} {2,8}  {3,6}     {4,6}"
        Dim str1, Start As String, str2 As String
        Dim var1, var2, total As Double
                Dim var3 As Double


        Start = my.ReadLine
        str1 = Start.Substring(0, 11)
        var1 = Start.Substring(12, 4)
        var2 = Start.Substring(16, 4)
var3 = Math.Round((var1 + var2) / 2, 0)
 lstBox.Items.Add(String.Format(fmtStr, str1, var1, var2, var3, str2))
That is a way to get information out of a line of a text file that contain a name and two variables and then the program does the math and adds the info to a list box. Hope that helps you get started.
 
Back
Top