How to get substring after a string in VB.NET

1 Answer

0 votes
Imports System
				
Public Module Module1
	Function StringAfter(str As String, a As String) As String
		Dim posA As Integer = str.LastIndexOf(a)
        
		If posA = -1 Then
            Return ""
        End If
        
		If posA + a.Length >= str.Length Then
            Return ""
        End If
		
		Return str.Substring(posA + a.Length)
    End Function

    Sub Main()
		Dim str As String = "VB.NET:C C++:Java"
        
		Console.WriteLine(StringAfter(str, "NET"))
    End Sub
End Module



' run:
'
' :C C++:Java
'

 



answered Oct 30, 2022 by avibootz
...