Visual Basic读取特定行

时间:2015-10-27 18:50:11

标签: vb.net loading streamreader

我正确地保存了可视基本代码,但我需要它来加载一个特定的行并将其设置为一个整数,这是我保存的代码

upload(droppedfile[i]);

当我使用它时,它会冻结,我必须使用任务管理器关闭它,还有另一种方法来格式化它以便它正常工作吗?

2 个答案:

答案 0 :(得分:0)

我发现通过删除do循环,代码将根据需要读取该特定行而不会使系统崩溃,跳过它跳过的行数。

Dim Red as Integer
    Dim b as String
    b = ""
            Dim objReader As New System.IO.StreamReader(Path)
                b = File.ReadLines(Path).Skip(1).Take(1).First()
            objReader.Close()
    val(b)
            Red = b
            TextBox2.Text = Red

答案 1 :(得分:0)

    dim myfilepath as string = "c:\myfilepath"
    If My.Computer.FileSystem.FileExists(myfilepath) Then
    dim mytext s string() = split(My.Computer.FileSystem.ReadAllText(myfilepath),vbCrLf)
    dim red as integer 
    dim  linecounter as integer = 0
    dim specificline as integer = "e.g." 0
    For linecounter 0 to ubound(mytext)
    if linecounter = specifline
    red = mytext(x)
    end if
    next

    end if