Hi, I need help with some questions for my Visual basic studios class 1)True or
ID: 3845014 • Letter: H
Question
Hi, I need help with some questions for my Visual basic studios class
1)True or False: Loops are used to repeat the same block of code.
2) True or False: The DO ... Loop Until construct will always execute the 'block' of code at least one time verses a Do While ... Loop construct which may not.
3) What is the purpose of this function:
Function XYZ(ByVal strIn as String) As Boolean
Dim bRet as Boolean = False
Dim intLength as Integer
Const conSPACE As String = " "
'
IntLength = strIn.Length
Do While (IntLength > 0 And bRet = False)
If Mid(strIn, IntLength, 1) = conSPACE Then
bRet = True
End If
IntLength -= 1
Loop
XYZ = bRet
End Function
4) True or False: The recommended way of processing files is to use the DO WHILE – LOOP method
5) True or False: In a For x= loop, updating the x inside the loop is the recommended way of exiting a loop.
6) What one key word is missing in this code segment:
‘Repeat as long as desired
Dim num as Integer
Dim answer as String = ""
Do
Num += 1
LstOutput.Items.Add(num)
Answer = InputBox("Do you want to continue (Y/N)")
Until answer.ToUpper = "N"
7) True or False: An infinite loop is when a DO – LOOP reaches a condition in which it will never exit the LOOP (or repeats the LOOP forever)
8) True or False: aryValues(i,j) = 10 is the correct way to set an element in a two dimensional array?
9)
Which is valid 'DO' constructs to perform a loop?
A) Do ... End Do
B) Until ... Done
C) Do While ... Loop
D) For ... Loop
10) What is wrong:
‘Displays All the Odd Numbers till 10
Dim num as Integer = 1
Do While num <> 10
LstOutput.Items.Add(num)
Num = num + 2
Loop
Explanation / Answer
1)True . Loops execute the block of code with initialization,condition and incrementation of number of times the block execute.
2) True. The DO ... Loop Until construct will always execute the 'block' of code as it checks the condition at the end after executing the block of code once.
3)
Function XYZ(ByVal strIn as String) As Boolean
Dim bRet as Boolean = False
Dim intLength as Integer
Const conSPACE As String = " "
'
IntLength = strIn.Length
Do While (IntLength > 0 And bRet = False)
If Mid(strIn, IntLength, 1) = conSPACE Then
bRet = True
End If
IntLength -= 1
Loop
XYZ = bRet
End Function
This function checks the string strln for space at the mid position and return true. If there is no space at the mid of the string it returns false.
4)
False Do Until EOF() is recommended for sequential access of files
5)
False eg For x = 1 To 10 , x is not updated indide the loop
6)
‘Repeat as long as desired
Dim num as Integer
Dim answer as String = ""
Do
num += 1
LstOutput.Items.Add(num)
answer = InputBox("Do you want to continue (Y/N)")
Loop Until answer.ToUpper = "N"
Loop
7) True - In infinite loop the condition never lets the control come out of loop
8) True
9)
C) Do While ... Loop
10) What is wrong:
‘Displays All the Odd Numbers till 10
Dim num as Integer = 1
Do While num <= 10
LstOutput.Items.Add(num)
Num = num + 2
Loop
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.