First Exam Review Questions 1. How to clear the pictureboxes, textboxes, and labels? Solution: Text1.Text=”” Label1.Caption=”” Picture1.Cls 2. What is the output of the following Code: a. Print “AB” & “CD” b. Print “AB”; ”CD” c. Print “AB” , “CD” d. Print “AB” & 1 e. Print “AB” ; 4 f. Print 3 & “AB” & 1 g. Print 3 ; “AB” ; 1 h. Print 3 , “AB” , 1 i. Print 4 ; “AB” j. Print 1 ; 2 k. Print 1 , 2 3. what is the output of the following code? right(left(“abcd”,2),1) len(left(“abcdefgh”,4)) 4. what is the result of int(rnd*15)+7? Sol: Displays a random Integer from 7 to 21 (7 and 21 included). 5. what is the result of 5 - Int(Rnd*5)? Sol: Displays a random Integer from 1 to 5 (1 and 5 included). 6. For the following code segment which choice is the more correct? Private Sub cmdSubmit_Click() txtPhrase.Font.Name = “Courier New” End Sub 1. Changes the text box’s font to “Courier New” 2. Changes the command button font to command 3. Changes the textbox text to read “Courier New” 7. What is wrong with the following event procedure? Private Sub cmd_Click() txtPhrase.Font.Italic = “Italic” EndSub 1. 2. 3. 4. 5. 6. The button has no Name! No space between End and Sub “Italic” is an invalid Assignment nothing 1,2,3 2, 3 8. Determine the output of the following code? a=2 b=3 c = b^3 + a /2 picDisplay.Print c, C, B 1. 2. 3. 4. 5. 14 c 28 28 14 C C 0 28 14 27 B 3 3 3 9. Determine the output of the following code? a=2 b = a*a^2/(4-2) c = 64/a^3+2 picDisplay.Print b; tab(8); c 1. 2. 3. 4. 5. 4 4 0 10 0 2 10 10 4 0 10. What is the output if we double click the cmdSubmit? Private Sub cmdSubmit_Click() a= (2 +3 * 4)/2 picOutput.print “a”, a EndSub 1. a 2. 7 3. a a 4. a 10 7 7 7 7 7 11. assume that the file “data.txt” contains: What is the output of the following code? 12. assume that the file “data.txt” contains: What is the output of the following code? 13. Determine the output of the following code? Private Sub Command1_Click() a=2 a=3 Print a; b=a*a^2 a=a^a Print a; c = 64 / a ^ 3 + 2 Print a a = 23 - x Print a End Sub 14. Determine the output of the following code? Private Sub Command1_Click() a=3 Print a - 1; a=a-1 a=a-1 Print a; Print a - 1; a + 1; a + 1 Print a End Sub 15. assume that the files “data1.txt” and “data2.txt” contain: Determine the output of the following code? Open "data1.txt" For Input As #1 Open "data2.txt" For Input As #3 Input #3, Num1, Num2 Input #1, Num3, Num4 Print Num1 + Num3 Print Num2 + Num4 Input #1, Num1 Input #3, Num3 Print Num1 + Num3 Close #1 Close #3 16. Determine the output of the following code? Private Sub Command1_Click() a=2 a=3 picBox1.Print a; b=a*a^2 a=a^a picBox1.Print a; c = 64 / a ^ 3 + 2 picBox1.Print a a = 23 - x picBox1.Print a picBox1.Cls End Sub 1. Nothing print 2. 3 27 27 23 3. 23 4. 3 27 27 23 17. When the user clicks a button, _________ is triggered. a. An event b) a method c) a setting 18. What will be the contents of the variable x after the following statement is executed? x= Sqr(((9+7)/(4*2))+2) Ans=2 19. What is the output of the following code? Private Sub Command1_Click() Dim s1 As String, s2 As String, s3 As String s1 = "abcd" s2 = "hello" s3 = "CS116Visual Basic.&" picBox1.Print Mid(s3, 10, 5) picBox1.Print Mid(s3, 5) picBox1.Print Len(s2 & s1) picBox1.Print Mid(Left(s2 & s3 & s1, 10), 5, 6) picBox1.Print Len(Mid(Left(s2 & s3 & s1, 10), 5, 6)) picBox1.Print Right(s3, Sqr(7 + Int(2.1))) picBox1.Print Mid(s2 & s3, Len(s1), Len(s1) + 5) End Sub 20. Determine the output of the following code? Dim s1 As String, s2 As String, s3 As String s1 = "abcd" s2 = "hello" s3 = "CS116Visual Basic.&" picBox1.Print InStr(s2, s3) picBox1.Print InStr(s2, "he") picBox1.Print InStr(s2, "h e") picBox1.Print InStr(s2, "ll") picBox1.Print InStr(s2, "lo") picBox1.Print InStr(s3, " ") picBox1.Print InStr(s2, "basic") picBox1.Print InStr(12, s3, "s") ' start from position 12 End Sub 21. what would be a good name for a text box to hold a persons first name a) txtFirstName b) txt First Name c) FirstName d) txt_x 22. The following statements Int(Rnd*19 /2) will generate a number in the range of _______________? a) 0 through 19 b)0 through 20 c) 0 through 9 d) 1 through 9 23. Determine the output of the following code? Private Sub Command1_Click() picBox1.Print Int(9.2) picBox1.Print Int(-9.2) picBox1.Print Int(9.5) picBox1.Print Int(9.8) picBox1.Print Int(-9.9) End Sub 24. what is displayed by txtBox.Text = Chr(65) & “BC” sol= ABC 25. the visual basic verb that creates a variable is _____? a) Declare b) Dim C) Create D) none of these 26. Determine the output of the following code? Private Sub Command1_Click() picBox1.Print FormatPercent(2 / 3, 4) picBox1.Print FormatPercent(0.125) picBox1.Print FormatPercent(0.125, 0) picBox1.Print FormatNumber(1500600.235) picBox1.Print FormatNumber(1500600.235, 1) picBox1.Print Format(600.2, "@@@@@@") Dim x As Integer, y As Single x = 10 y = 0.531 s1 = FormatNumber(x, 0) s2 = FormatPercent(y, 2) picBox1.Print x; y picBox1.Print s1; s2 End Sub 27. Determine the output of the following code? Private Sub Command1_Click() Dim x As Integer Dim y As String Dim z As Single picBox1.Print picBox1.Print picBox1.Print picBox1.Print y x w z End Sub 28. Determine the output of the following code? Dim str as String Str=”Irbid-Jordan” picBox1.Print Left(str,Instr(str,”J”)) Solution= Irbid-J 29. consider the following event procedure Private Sub cmdTest_Click() n = txtNum1.Text m = txtNum2.Text picBox1.Print “n+m = ”; n + m End Sub If the user enters the value 10 in the text box (txtNum1), and 20 in the text box 2 (txtNum2) what will be the output of the above code Solution: n+m = 1020
© Copyright 2026 Paperzz