2015-10-31 48 views
-4

我的代码:VB.net读取特定行文本

Dim stateoffullscreen() As String 
    stateoffullscreen = File.ReadAllLines("settings.txt") 

    If stateoffullscreen(1) = "fulllscreen:true" Then 

     cb_fullscreen.Checked = ("true") 

    Else 

     cb_fullscreen.Checked = ("false") 

    End If 

所以这个脚本检查是否在第2个看台设置文件(settigns.txt):调试:如果是那么它会激活一个复选框,如果没有则不会。

设置文件

Last load : 31.10.2015 22:46:23 - 31.10.2015 

fullscreen:true 

debug:false 

debuglog:false 

请帮我没有找到错误,因为stateoffullscreen是alwas调试:假的,即使我更改行号

stateoffullscreen(“行号码“

+1

设置文件中每个文本行之后是否有空行?如果是,那么将这一个也计为一行,所以'debug:false'将是行号** 5 **(数组中的索引4) – haraman

+0

试试这个:'cb_fullscreen.Checked = stateoffullscreen.Any(Function(x)x =“fulllscreen:true”)'而不是你的'If'语句。 – Enigmativity

+1

哦,你是不是打算在'fulllscreen'里有3个'l'? – Enigmativity

回答

0

你声明

stateoffullscreen = File.ReadAllLines( “SETTINGS.TXT”)

但随后

所以这个脚本检查是否在设置在文件(settigns.txt) 第2行代表:debug:如果是,则为true,那么它会激活复选框,如果不是 则不启用。

If stateoffullscreen(1) = "fulllscreen:true" Then 

您插入全屏3 'L'。