Is string in start of other string?

I need to know, how to find out if string 1 in in the start of string 2.

Example: string1: test / string2:testing = returns true
string1: test /string2: gettested = returns false



Answer this question

Is string in start of other string?

  • TDT99

    Or you could do a comparison using the substring method

    dim s as string = "test"
    dim t as string = "test string"

    if t.substring(0,4) = s then '//This will be true

    end if

    Of you could use the left$ method (But this is older Basic method)

    if left$(t,4) = s then '//This will be true

    end if


  • robinjam

    Take a look at the string's startswith function.


  • Is string in start of other string?