String function in Visual Basic

0
145

In this topic, you will learn about, String functions that are supported by Visual Basic.

Len(length): this function is used to calculate the length of the string. Its offers the facility to return a number of letters, numbers, or symbols.

Eg: Dim Str as String
Dim l as integer
Str =inputbox(‘’enter any number:’’)
L=len(str)
Msgbox(‘’length of string:’’&l)

Ucase: using this function we can convert given lowercase into uppercase.

Dim Str as String
Str =inputbox(‘’enter any string:’’)
Msgbox(‘’string in uppercase:’’&ucase(str))

Lcase: using this function we can convert given uppercase in lowercase.
Dim Str as String
Str =inputbox(‘’enter any string:’’)
Msgbox(‘’string in lowercase:’’&lcase(str))

StrReverse: StrReverse used to reverse the contents of one string and store them in another string.
Eg:- Dim Str1 as String
Dim Str2 as String
Str1=inputbox(‘’enter any number:’’)
Str2=StrReverse(Str1)
Msgbox(‘’String after reverse:’’str2)

Mid: This function return number of letter or substring from a given string where we can specify start position and number of characters.
Eg:- Dim Str1 as String
Dim Str2 as String
Str 1=inputbox(‘’enter any string’’)
Str2=mid(str1,5,4)
Msgbox(‘’sub string:’’&str2)

Comment below if you have queries related, String functions that are supported by Visual Basic.

LEAVE A REPLY

Please enter your comment!
Please enter your name here