本文介绍了在特定点开始和结束阅读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从txt文件中读取一个值.我在什么之后开始和结束在特定点.我要读取的值是:
...
fCloudNearFadeDistance = 9000.0000
...
我不知道如何获取"="之后的数字,即."之后的数字,即9000.
到目前为止,我一直在使用此代码从文本文件中获取此类数字,但在读取带有."的数字时会引发异常.
I want to read a value from a txt file. What i''m after starts and ends at specific points. the value i''m trying to read is:
...
fCloudNearFadeDistance=9000.0000
...
I couldn''t figure out how to get the number after "=" and before ".", namely 9000.
Up till now i was using this code to get such numbers from my text file but it throws an exception when reading numbers with "."
Dim cloudfadeout As Integer
For Each k As String In IO.File.ReadLines(dir + "\My Games\Skyrim\SkyrimPrefs.ini")
If k.Contains("fCloudNearFadeDistance=") Then
Dim values() As String = k.Split(CChar("="))
cloudfadeout = Convert.ToInt32(values(1))
End If
Next
Form2.TrackBar6.Value = cloudfadeout
VB 2010/.NET 4.0
VB 2010 / .NET 4.0
推荐答案
cloudfadeout = Convert.ToInt32(Convert.ToDecimal(values(1).Replace(".",",")))
这篇关于在特定点开始和结束阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!