(Paper) Class XII Informatics Practices: Chapter Wise Papers (LIBRARY FUNCTIONS)
Disclaimer: This website is NOT associated with CBSE, for official website of CBSE visit - www.cbse.gov.in
Class XII Informatics Practices Paper (Chapter Wise With Answer)
LIBRARY FUNCTIONS
1 Define the term Library Functions in Visual Basic. Name the
different categories of library functions available in Visual Basic. Give the
usage and syntax of any two library functions.
Sol.: Visual Basic offers many functions that are pre-defined or built-in
into the VB interpreter, which can be used directly in any program. These
functions are highly reliable and can tremendously reduce the amount of coding
required for a program.
Different categories are:
1. Numeric functions e.g Int(),Fix()
2. String functions e.g Mid(),Ucase()
3. Date Functions e.g Now(),date()
4. Miscellaneous function e.g Isdate(), Isnumeric()
Syntax of Mid Function
Mid ( string, start position, no. of char) : - Mid function is used to extract
characters from the middle of a string . We need three arguments : The original
string , the place to start extracting and the number of characters to extract.
Syntax of InStr function
InStr(start,string1,string2,compare):- Instr function searches for string within
string. Its first string is position in the string to start searching. The
second argument is the string to search in. The third argument is the string .to
search for and the last argument is whether or not you want a case-sensitive
search.(0 for yes, 1 for no) .
2. Write the output that the following code segment will generate :
x=”Class”
Print Mid (LTrim( “Computer Science” ),1,4)+”One”
Print(7*4>8+3) And (3^2 < 6/2)
Print Val(“l6 oranges”) + Len(x)
Print InStr(“Computers”, “ut”)
Sol.:
CompOne
False OR 0
21
5
3. Write the output that the following code segment will generate
Stringl = “Class XII”
String2 = “XI”
Print Stringl + String2
Print InStr (Stringl, String2)
Print Mid (LCase(Stringl), 6, 3 )
Print Int(4.7) + Len(String2)
Sol.:
Class XIIXI
7 OR 6
xi OR xii
6
4. Check that in the text box for Employee code (txtEmpCode) only numeric
data is entered.
sol.: If Not(IsNumeric(txtEmpCode.Text)) Then
Msgbox (“Please enter numbers only”)
End If
OR
If Not(Right(txtEmpCode.text,1) >= “0” And
Right(txtEmpCode.text,1) <=”9”) then
txtEmpCode.text = “” or msgbox(“Enter only numeric value”)
End if
5. Write a Visual, Basic procedure which takes a string as argument and
displays the following:
- The string in uppercase
- The length of the string
- The string with its first and last characters in uppercase and all the other
characters in lowercase.
Sol.: Sub Procname(str as string)
Dim newstr, L
Print UCASE (str)
L = LEN(str)
Print L
newstr = UCASE (LEFT(str, l)) OR (UCASE (MID (str,1,1))
+ LCASE (MID(str, 2, L-2))
+ UCASE(RIGHT(str, 1)) OR (UCASE (MID (str,L-l,1 ))
Print newstr
End Sub