Monday, February 6, 2017

Try some Functions In Program..Visual Basic


Use of Len ,Right Function in Visual Basic
These are small functions included in the Framework that we work in VB. These functions are important and useful for making our project successful.
1.       Len : This is a function which helps to find out the length of any string assigned in the function. It is used for counting the length of characters in a string. It counts space also. The length function returns an integer value which is the length of a phrase or a sentence, including the empty spaces.
Syntax:
len(string)   continue...

For example: If we want to find out the length of string defined in any variable defined
Dim str as String
Dim IntLenght as Integer
Str=”Nepal”
intLenght = len(str)

Result : 5






In above image , len is used to in a loop for counting length of any string input in a variables.

2.       Right : This function if used to count the length of any string from right side of the defined string.  It needs two values. First one is string itself and other one is ending point of the length.

Syntax: Right(string , n)

It counts string characters from right hand side to n numbers .

For  example:

If x =”Nepal”

Then  right(x,3)

Result : pal











In above image use of Right function is used with variable string txt1.text and ending length of I.
It displays the letters from  right hand side with ending point increasing with loop. This is a dynamic example with dynamic ending points of the string value. Where n is the starting position from the right of the phrase where the portion of the phrase is going to be extracted.

Try and enjoy the code.


Narayan Aryal
Butwal  Nepal

No comments:

Post a Comment