Write a Visual basic program to count the number of char in a string

How to Write a Visual basic program to count the number of char in a string or Find the length of string in visual basic. Visual Basic program to find the index of char in string.

Below are examples of visual basic programs. will see how to find the length of a string and index of char in visual basic. Visual basic programs with examples to deal with string.

Visual basic program to count the number of char in a string

In this example, We are using s.Lenght to find the length of a string where S is a string.

Module Module1	
    Sub Main()
 
        Dim s As String
        s = "Hello Codebun"
        Console.WriteLine("Lenght of string is: " & s.Length)
        Console.ReadLine()
 
    End Sub
 
End Module

Output: Lenght of string is: 13

Vb program to find the index of a char in string

In this example, We are using s.IndexOf(“o”) to find the index of “o” from the string s=”Hello Codebun” is a string.

Module Module1
 
    Sub Main()
 
        Dim s As String
 
        s = "Hello Codebun"
 
        Console.WriteLine("Index of: " & s.IndexOf("o"))
        Console.ReadLine()
    End Sub
 
End Module

Output: Index of O is: 4

Check out more related visual basic program with example

Vb program to find the sum of digit

Vb Program to create the multiplication table

Add a Comment

Your email address will not be published. Required fields are marked *

two + 1 =