R
RedFox
Hello, I'm a beginner at programming and started working on a specific
console program that uses StreamReader to go through the code and find
required data, then check if lines Contain or StartWith with certain strings.
The problem is that the current split method to separate Data isn't very
efficient if the text has tabs and spaces in it, instead of just tabs for
example. Is there a way to properly identify a specific section of a line,
while using only one Sub (Sub Main()), since I'm not very skilled at that yet
and the whole program is a set of GoTo loops until everything is finished.
Here's what the line looks like:
faction seleucid ; The Seleucid Empire
And the empty characters can occur pretty randomly:
faction[TAB][TAB][randomspaces][TAB][space]seleucid[space]; The Seleucid
Empire
Here's the initializing piece of code, where [sr] is the streamreader for
the correct .txt file:
Do
line = sr.ReadLine()
If line Is Nothing Then
GoTo FinishedAll
End If
Loop Until line.StartsWith("faction")
So far I've used split functions, but I'm not sure that's the right way.
What I need is for it to always correctly retrieve "seleucid" as String
CurrentFaction and ignore all text after a comment mark ";".
Hope you can help me out with this! I really love programming so far, but
Subs still leave me confused and all the more complex functions require
really good knowledge of how Subs act, which I don't have.
Regards,
- RedFox
console program that uses StreamReader to go through the code and find
required data, then check if lines Contain or StartWith with certain strings.
The problem is that the current split method to separate Data isn't very
efficient if the text has tabs and spaces in it, instead of just tabs for
example. Is there a way to properly identify a specific section of a line,
while using only one Sub (Sub Main()), since I'm not very skilled at that yet
and the whole program is a set of GoTo loops until everything is finished.
Here's what the line looks like:
faction seleucid ; The Seleucid Empire
And the empty characters can occur pretty randomly:
faction[TAB][TAB][randomspaces][TAB][space]seleucid[space]; The Seleucid
Empire
Here's the initializing piece of code, where [sr] is the streamreader for
the correct .txt file:
Do
line = sr.ReadLine()
If line Is Nothing Then
GoTo FinishedAll
End If
Loop Until line.StartsWith("faction")
So far I've used split functions, but I'm not sure that's the right way.
What I need is for it to always correctly retrieve "seleucid" as String
CurrentFaction and ignore all text after a comment mark ";".
Hope you can help me out with this! I really love programming so far, but
Subs still leave me confused and all the more complex functions require
really good knowledge of how Subs act, which I don't have.
Regards,
- RedFox