Find occurence in string with line number?
Posted: Fri Jan 29, 2010 4:00 am
Hi guys,
Kind of stuck at this problem for a while...
I am trying to make a basic error checking routine which checks for open brackets or extra brackets.
The idea is to find { bracket with line numbers then find } with line numbers
Then start subtracting each occurrence until you are left with nothing or brackets. If you are left with brackets that mean these are extras or open.
How can I do this... :(
I have a code to find the occurence but I can't seem to get the line numbers. I am using an RTB.
-Toxikr3
Kind of stuck at this problem for a while...
I am trying to make a basic error checking routine which checks for open brackets or extra brackets.
The idea is to find { bracket with line numbers then find } with line numbers
Then start subtracting each occurrence until you are left with nothing or brackets. If you are left with brackets that mean these are extras or open.
How can I do this... :(
I have a code to find the occurence but I can't seem to get the line numbers. I am using an RTB.
Code: Select all
Hope some can help Dim strText As String
Dim strSearchText As String
Dim strSearchText2 As String
Dim index As Integer
Dim count As Integer
Dim count2 As Integer
strText = RTB.Text
strSearchText = "{"
strSearchText2 = "}"
count = 0
count2 = 0
For index = 0 To strText.Length - 1
If strText.Substring(index, 1) = strSearchText Then
count = count + 1
End If
Next
For index = 0 To strText.Length - 1
If strText.Substring(index, 1) = strSearchText2 Then
count2 = count2 + 1
End If
Next
Dim h As Integer
h = count - count2
If h <= -1 Then
ListBoxErrors.Items.Add("Missing {")
End If
-Toxikr3