Hi, I need help with these questions for my Visual Basic Studio class. Thanks in
ID: 3796211 • Letter: H
Question
Hi, I need help with these questions for my Visual Basic Studio class. Thanks in advance
1)True or False: Inputbox is an example of a builtin function.
2)True or False: Functions always have one value returned at the end of that invocation.
3)True or False: Functions must always have at least one parameter or argument passed to them.
4)True or False: (“Class” < “Clasr”) OR (“Z” <> “z”)
5)True or False: Math.Round is an example of a built-in function.
6)True of False: Functions can have arguments passed by either ByVal or ByRef.
7)True or False: Not (((3 <= 5) And (5 <= 0)) Or (5 <> 4))
8) Write a function called “SquareIt” which will square any Long passed to it, and return a Single
9)
What does this function return:
“OneTwoThreeFour”.Substring(3,3)
10)
What is wrong with this Function prototype:
Function ReturnString(ByRef strReturn as String)
Explanation / Answer
1)
True
Input Box allows the user to enter input in a form. It is predefined in Visual Basic. Thus, this is an in-built function.
2)
False
Functions can return multiple values, but using a single variable only. It can return array of values.
3)
False
Function can be defined without any parameter also. It is not compulsory for a function to have a parameter.
4)
True
“Class” is greater than “Clasr” as ASCII value of “r” is less than “s”, thus, this condition returns false. “Z” is not equal to “z”, thus, this condition is true. Both expressions are connected by OR operator. Thus, the complete expression will return True.
5)
True
Math.Round is in-built function and is used to round the numbers as given in its parameters.
6)
True
In VB, there are two ways to pass arguments in a function: by value and by reference. Only these two methods are there to pass arguments.
7)
False
(3<=5) AND (5<=0) will be checked first which is enclosed in parenthesis. As (3<=5) returns false and (5<=0) returns false. It will return False AND operator between them.
(5<>4) will return True as 5 is not equal to 4.
OR operator is used between both expressions. Thus, expression (3<=5) AND (5<=0) OR (5<>4) will return true.
NOT is applied on whole expression. Thus, the whole expression will return False.
8)
Function SquareIt(By Val a as long) As Single
Return a*a;
End Function
9)
A string – “Two”
OneTwoThreeFour.Substring(3,3) will return Two.
First argument tells the starting index of the string and second index of the string tells the length of the string. String indexing starts from 0. Thus, Starting from T which is at index 3, it will return 3 letter substring. Hence, the returned value is Two and the return type of it is string.
10)
The function prototype in VB is as follows:
[Modifier(optional)] Function FunctionName[Arguments] As ReturnType
The given prototype,
Function ReturnString(ByRef strReturn as String) is not in the defined as in the above protoptype.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.