H
Herfried K. Wagner [MVP]
* "Cor Ligthert said:As a matter of fact ,reading XML is quite simple, I use it all the time.
Sure, but what's going on behind the scenes is more compilcated.
* "Cor Ligthert said:As a matter of fact ,reading XML is quite simple, I use it all the time.
Maybe you can ask Terry if you can buy that old commodore 64 from him,* "Cor Ligthert said:Sure, but what's going on behind the scenes is more compilcated.
jcrouse said:Thanks for the code Greg. I implemented it. As far as my problem goes I
figured it out and it's a little embarrassing but maybe someone else can
learn, CHECK YOUR CASE SENSATIVITY!.
Duh,
John
Greg Burns said:This is really no better or worse than your code, just the method I prefer
when looping through a text file.
HTH,
Greg
(untested)
' equivalent, take your pick...
Dim sr1 As StreamReader =
File.OpenText(System.IO.Path.Combine(Application.StartupPath,
"Controls.ini"))
'Dim sr1 As StreamReader = New
StreamReader(System.IO.Path.Combine(Application.StartupPath,
"Controls.ini"))
Dim bGameExists As Boolean = False
Dim strLine As String
Dim strParentName As String = "somevalue"
strLine = sr1.ReadLine()
Do While Not strLine Is Nothing
Dim intCheck As Integer = 0
intCheck = InStr(strLine, "[" & strParentName & "]")
If intCheck > 0 Then
bGameExists = True
Exit Do
End If
strLine = sr1.ReadLine()
Loop
sr1.Close()
If bGameExists = True Then
'do something
Else
'do something else
End If
jcrouse said:Here is my code:
Dim sr1 As StreamReader = New StreamReader(Application.StartupPath &
"\Controls.ini")
strGameExists = "no"
intCheck = 0
Do
strLine = sr1.ReadLine()
intCheck = InStr(strLine, "[" & strParentName & "]")
If intCheck > 0 Then
strGameExists = "yes"
End If
Loop Until intCheck > 0 Or strLine Is Nothing
sr1.Close()
If strGameExists = "yes" Then
do something
else
do something else
End if
The code works great in the debugger. It finds the string, sets
strGameExists to "yes" and executes my code. However, at runtime it always
executes my do something else code. Am I missing something here?
Thank you,
John
* "One Handed Man \( OHM - Terry Burns \) said:It doesent really matter, the point is that reading an XML file is far more
structured and useful.
That doesent answer the OP's questions Lucas.
I doubt that it's easier to read. It's much more complicated to parse.
Because that you can read it (a computer in a humanbox) does not mean thatNo!
XML is /not/ useful in all situations because it's not human-readable.
It's designed for easy processing my /machines/ and not for
edititng/reading by humans. So, INI files are far more comfortable,
they support nested data structures too, and they can be parsed easily.
jcrouse said:CHECK YOUR CASE SENSATIVITY!.
* Lucas Tam said:If case sensitivity is not important in your program, Ucase/Lcase any
comparisons before hand so you'll have uniform cases.
* "One Handed Man \( OHM - Terry Burns \) said:XML is is usefull in most situations, it IS human readable and IS easy to
navigate, there is a whole group of classes dedicated to doing just that.