genespos genespos - 6 months ago 29
Vb.net Question

check if string starts or ends with vbcrlf

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

vbcrlf
?

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

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

Answer

Try this

StartsWith - checks the first part of a String.

    Dim s As String = "vbCrLf bla bla bla"

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

EndsWith - checks the last characters of a String.

    Dim s As String = "bla bla bla vbCrLf"

    If s.EndsWith("vbCrLf") Then
        MsgBox("Yes")
    End If
Comments