I have a program that reads in data, into a string. The data being entered into the string could be a few paragraphs long.
Right now, I'm running a series of If ... Then... Else statements to make my way through the string and grab key data points.
Is there a faster way to do this, right now, the scan takes quite a long time to complete and I feel as though there must be a better way?
For example, my string may have this for data:
[hello]This is an example of a Hello greeting.[/hello]
[else]This is an example of another line.[/else]
[etc...]...etc...[/etc]
My code looks something like this assuming strMyData is the string, already read in:
Right now, I'm running a series of If ... Then... Else statements to make my way through the string and grab key data points.
Is there a faster way to do this, right now, the scan takes quite a long time to complete and I feel as though there must be a better way?
For example, my string may have this for data:
[hello]This is an example of a Hello greeting.[/hello]
[else]This is an example of another line.[/else]
[etc...]...etc...[/etc]
My code looks something like this assuming strMyData is the string, already read in:
Code:
Dim iLocation1 As Integer = "0"
Dim iLocation2 As Integer = "0"
Dim iLocDiff As Integer = "0"
Dim strDataHolder As String
iLocation1 = strMyData.IndexOf("[hello]")
iLocation2 = strMyData.IndexOf("[/hello]")
iLocDiff = iLocation2 - iLocation1
strDataHolder = strMyData.Substring((iLocation1+7), iLocDiff - 7))
'The +7 and -7 are to compensate / to pull out the TAGS from the actual data I want to get
'Then I do something with strDataHolder and repeat the process until all of my tags are met (it's a static number, I'm looking for about 10 data points).
iLocation1 = strMyData.IndexOf("[else]")
iLocation2 = strMyData.IndexOf("[/else]")
iLocDiff = iLocation2 - iLocation1
strDataHolder = strMyData.Substring((iLocation1+6), iLocDiff - 6))
'The +6 and -6 are to compensate / to pull out the TAGS from the actual data I want to get
'Do something with strDataHolder
'etc.etc.etc.