Click here to Skip to main content
16,013,082 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 "."

VB
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
Posted

1 solution

before convert to int 32 pls convert to decimal and dont forget replace "." with ","
like this
VB
cloudfadeout = Convert.ToInt32(Convert.ToDecimal(values(1).Replace(".",",")))
 
Share this answer
 
Comments
theraveman 19-May-12 10:57am    
Thanks a lot!
Dain Ucak 19-May-12 10:58am    
yw

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900