0

i am writing a vb.net program which gets a c program as an input and checks it for errors,now i want my program to skip the comments in the c program,i have written some code but its not working pls tell me where i have gone wrong,or if u have any ideas pls let me know

For Each line In TextBox1.Lines
sample = TextBox1.Lines(k)
Dim len As String
len = sample.Length
comm = InStr(sample, "/*")
If comm <> 0 Then
comm = 0
Do While comm = 0
For Each line1 In TextBox1.Lines(k)
sample = TextBox1.Lines(k)
len = sample.Length
For i = 0 To len - 1
comm = InStr(sample, "*/")
Next
If comm <> 0 Then
Exit Do
End If
k = k + 1
Next
Loop
Next
End If

Edited by ritesh2190: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by sandeepparekh9
0

hi..

sorry for posting c#.net code..

here is the vb.net version of same function..

Public Shared Function FindStringBetween(strData As String, strFindWhat As String) As List(Of String)
	Dim lstFound As New List(Of String)()
	Dim startIndex As Integer, EndIndex As Integer
	startIndex = strData.IndexOf(strFindWhat)

	EndIndex = strData.IndexOf(strFindWhat, startIndex + strFindWhat.Length)

	If EndIndex > 0 Then
		lstFound.Add(strData.Substring(startIndex + strFindWhat.Length, EndIndex - startIndex - strFindWhat.Length))
	End If

	While EndIndex > 0
		startIndex = strData.IndexOf(strFindWhat, EndIndex + 1)
		If startIndex = -1 Then
			Return lstFound
		End If
		EndIndex = strData.IndexOf(strFindWhat, startIndex + 1)
		If EndIndex > 0 Then
			lstFound.Add(strData.Substring(startIndex + strFindWhat.Length, EndIndex - startIndex - strFindWhat.Length))
		End If
	End While

	Return lstFound
End Function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.