|
-
Dec 13th, 2002, 07:55 PM
#1
Thread Starter
Hyperactive Member
Text Files [ Resolved ]
I am new so no yelling please 
ok here is what I want... please help
I want to have a text file that reads:
Background = Red
Text = Blue
Size = 5
now how do I access it from my application and get the "values"
by opening the file and reading line by line?
and lets say later I may want to change setting to something else?? like change the size option to 10?? how do i read the file get the value and then change it??
Please help
Thanks,
Anjari
Last edited by Anjari; Dec 20th, 2002 at 05:22 AM.
-
Dec 13th, 2002, 08:41 PM
#2
yay gay
the easy way is get some class that reads ini for u and do something like that with INI's...otherwise u'd must have to create ur own engine -_-;;;
u can use xml too, but the sintax will be a kind diferent
\m/  \m/
-
Dec 13th, 2002, 09:04 PM
#3
to read a file:
VB Code:
' at the top of the code
imports system.io
' in a sub or function
Dim sr As StreamReader = File.OpenText("filepath")
Dim aLine As string
aLine = sr.ReadLine()
' make sure you close the file! :)
sr.Close()
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Dec 13th, 2002, 09:18 PM
#4
Thread Starter
Hyperactive Member
hmmmm
Mr. Polite could you go into detail for a newbie? 
how do i pull each value?
Thanks,
Anjari
-
Dec 13th, 2002, 09:51 PM
#5
Re: hmmmm
Originally posted by Anjari
Mr. Polite could you go into detail for a newbie? 
how do i pull each value?
Thanks,
Anjari
well that;s just for reading the lines from the file here's how to read all the lines, one by one...
btw this is my way of reading the values from the lines, you can come up with any way you want 
VB Code:
' open the file .... you should add an error handler
Dim sr As StreamReader = File.OpenText("c:\test.txt")
Dim aLine, value As String
Dim delimPos As Integer ' Holds the position of the delimiter ("=") in the line
' Read until the end of the file
Do While sr.Peek() <> -1
' Read a line from the file
aLine = sr.ReadLine()
delimPos = aLine.IndexOf("=")
If delimPos = -1 Then
' Error, no delimiter found!
' throw an error ...
Else
' Get the value from the line
value = aLine.Substring(delimPos + 1)
' Remove extra spaces
value = value.Trim()
End If
' Do whatever you want with the value right here
Loop
' Close the file
sr.Close()
hope this helps
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Dec 20th, 2002, 05:21 AM
#6
Thread Starter
Hyperactive Member
Works Great
Thanks again...
Anjari
*** Don't Shoot the newbie! ***
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|