N/APosted on - 04/10/2015
I want to know what is the use of functions? What are the different syntaxes that I can use for the functions? Can you provide me description for each function? What is the use of input box? Can you show me the declaration using an input box? What do you mean by CSng? What is the use of it? What is the meaning also of LCase? What is the use of it in VB program? Why do we always have to use “Val” in declarations or syntaxes?
Please help me with this!
Learning more information in Visual Basic 2015
Functions – a named block of code that performs an action or return any value.
Here are the common functions used in VB.
1. LCase(string) – converts all characters to lower case.
2. Len(string) – returns the number of characters in a string.
3. Day(date) – returns the day of the month.
4. CSng(expression) – converts the value of expression to a single data type.
5. CStr(expression) – converts the value of expression to a String data type.
“Is one plus one equals to 11”? Yes it is correct in computer systems. Computers doesn’t know how to think. We are still the masters here.
Val – is used to take only the numerical value. In using textbox, numbers of integers will be considered characters. So if you will not use Val it will just put together the strings. For example >>>
Two textboxes with name txt1 and txt2. The values inside of each boxes is 1 and 2 respectively. Without using if you will just do it like this:
The answer is 12. To correct this you need to declare sum = Val(txt1)+Vale(txt2). The answer now will be 3.