.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

String Functions In VB.NET

Posted By:Abhisek Panda       Posted Date: November 14, 2009    Points: 25    Category: General    URL: http://www.dotnetspark.com  
 

String Functions In VB.NET


Some of the String Handling functions in VB.NET are follows,

Len(String):- This function returns an integer containing the number of characters in the specifies string including spaces or no. of bytes required to store the variable.

Dim Str As String,Len As Integer
Str="Welcome"
Len=Len(Str)'returns 7

Space(int):- It returns a string containing the specified nmber of spaces.

Dim Str As String
Str=Space(5)'return a string with 5 spaces.
Str="Hello"&Space(5)&"INDIA" 'it will add 5 spaces between two strings.

LCase(String):- This function translates all upper case characters in a string to lower case.

Dim Str,LStr As String
Str="Welcome"
LStr=LCase(Str)'returns "welcome"

UCase(String):-This function translates all lower case characters in a string to upper case.

Dim Str,LStr As String
Str="Welcome"
LStr=LCase(Str)'returns "WELCOME"

RTrim(String):- It returns a string after removing trailing spaces from a string.
LTrim(String):- It returns a string after removing leading spaces from a string.
Trim(String):- It returns a string after removing trailing as well as leading spaces from a string.

Dim Str,tStr As String
Str=" Welcome "
tStr=Trim(Str)'returns "Welcome"
tStr=RTrim(Str)'returns " Welcome"
tStr=LTrim(Str)'returns "Welcome "
tStr=RTrim(LTrim(Str))'returns "Welcome" same function as Trim()

StrReverse(String):- This function reverse the specified string.

Dim Str,RStr As String
Str="Welcome"
RStr=StrReverse(Str)'returns"emocleW"

StrComp(String1,Strins2,[Compare]):- This function is used to compare two string for there values. Here compare is an optional argument that specifies type of comparision.

Asc(String):- It returns an integer representing the ASCII code corresponding to the first letter of the specified string.

Dim no As Integer
no=Asc("A")'returns 65
no=Asc("a")'returns 97
no=Asc("Microsoft")'returns 77

Chr(Int):- This function takes the ASCII character code as argument and returns the character corresponding to the code.

Dim Ch As String
Ch=Char(65)'returns "A"
Ch=Char(97)'returns "a"
Ch=Char(77)'returns "M"

There are also many more string functions in VB.NET, but these are frequently used functions.
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend