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

Can you post a sample of code from your C program, that includes comment lines?

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.