VB.Net Program to Demonstrate the Instr() Function

You are currently viewing VB.Net Program to Demonstrate the Instr() Function

VB.Net program to demonstrate the InStr() function

'VB.Net program to demonstrate the InStr() function.

Module Module1

    Sub Main()
        Dim str As String = "I love india"
        Dim substr As String = "love"

        Dim ret As Integer = 0

        ret = InStr(str, substr)

        If ret = 0 Then
            Console.WriteLine("Substring {0} is not found", substr)
        Else
            Console.WriteLine("Substring {0} is found at index {1}", substr, ret)
        End If

    End Sub
    
End Module

Output

Substring love is found at index 3
Press any key to continue . . .

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply