genespos genespos - 2 years ago 139 Question

check if string starts or ends with vbcrlf

How can I check if a string starts (or ends) with


I've tryed with
but it doesn't seems to work:

Dim s As String = ""
s &= vbCrLf & "Test"
If s.Substring(0, 1) = vbCrLf Then
End If

Answer Source

Try this

StartsWith - checks the first part of a String.

    Dim s As String = "vbCrLf bla bla bla"

    If s.StartsWith("vbCrLf") Then
    End If

EndsWith - checks the last characters of a String.

    Dim s As String = "bla bla bla vbCrLf"

    If s.EndsWith("vbCrLf") Then
    End If
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download