locked
How to detect a part of a string from a string? RRS feed

  • Question

  • Hi,

    How do i detect a part of a string from a string?


    For example:
     i want to check if the part of the string "mummy" exists in a string:


    "Mummy loves Daddy and loves me too"


    How do i code it?


    Monday, July 6, 2009 1:37 AM

Answers

  • Dim SearchWithinThis As String = "Mummy loves Daddy and loves me too"
    Dim SearchForThis As String = "Mummy"
    Dim FirstCharacter As Integer = SearchWithinThis.IndexOf(SearchForThis)
    You can also change "Mummy with a string connected to a textbox, for a custom search.

    It'll return a number also so
    1 = True
    0 = False

    (Might be backwards on that, but it can be easily checked)
    • Proposed as answer by A.R.K. _ Monday, July 6, 2009 1:55 AM
    • Marked as answer by DarcDarc Monday, July 6, 2009 2:01 AM
    Monday, July 6, 2009 1:50 AM