Docsity

Questions on Introduction to Computer Programming Visual Basic - Assignment 2 | CS 0004, Assignments of Computer Science

Toggle sidebar
bg1
Written Homework 2 02/14/2008 Due: 02/21/2008
Chapter 4 Procedures and Functions
1. What is the difference between a sub procedure and a function?
2. What does it mean for a function argument to be passed by value (ByVal) (how does it differ
from pass by reference (ByRef))?
3. What is the difference between a Class-level variable and a local variable?
4. List three advantages of using sub procedures and functions.
Chapter 5 Decision Making (If Blocks)
5. What will be the output of the following code?
Dim maxNum As Double = 100
Dim numPresent As Double = 105
If numPresent > maxNum Then
txtDisplay.Text = “Fire Code Violation, kick” & (maxNum-numPresent) & “People out!”
Else
txtDisplay.Text = “OK”
End If
Chapter 6 Loops (Going in circles)
6. What will be the output in the ListBox (lstDisplay) after the following code has been executed
Dim startPoint As Integer = 1
Dim endPoint As Integer = 10
Dim counter As Integer
For counter = startPoint to endPoint step 2
lstDisplay.Items.Add(2 &”x”& counter &” = ”& 2*counter)
Next
Chapter 3.4 Strings
7. Consider the following code; what will be the value of the string variable strVar after the code is
executed?
pf2

Partial preview of the text

Download Questions on Introduction to Computer Programming Visual Basic - Assignment 2 | CS 0004 and more Assignments Computer Science in PDF only on Docsity!

Written Homework 2 02/14/2008 Due: 02/21/

Chapter 4 Procedures and Functions

  1. What is the difference between a sub procedure and a function?
  2. What does it mean for a function argument to be passed by value (ByVal) (how does it differ from pass by reference (ByRef))?
  3. What is the difference between a Class-level variable and a local variable?
  4. List three advantages of using sub procedures and functions.

Chapter 5 Decision Making (If Blocks)

5. What will be the output of the following code?

Dim maxNum As Double = 100 Dim numPresent As Double = 105

If numPresent > maxNum Then txtDisplay.Text = “Fire Code Violation, kick” & (maxNum-numPresent) & “People out!” Else txtDisplay.Text = “OK” End If

Chapter 6 Loops (Going in circles)

6. What will be the output in the ListBox (lstDisplay) after the following code has been executed

Dim startPoint As Integer = 1

Dim endPoint As Integer = 10

Dim counter As Integer

For counter = startPoint to endPoint step 2

lstDisplay.Items.Add(2 &”x”& counter &” = ”& 2*counter)

Next

Chapter 3.4 Strings

7. Consider the following code; what will be the value of the string variable strVar after the code is executed?

Dim strVar As String Dim str1 As String = “Visual Basic is very easy” strVar = str1.SubString(7,5) & “ “ & str1.SubString(13,2) &” “& str1.SubString(21,4)