View
 

Lab 18: Swapper

Page history last edited by Mr. Kretsch 3 months ago

Name: __________________________

Objective: Write subroutines that uses call by reference.

Quiz

Consider the following subroutine:

Private sub Concat(ByVal a as String, ByRef b as String)

     a = a.substring(0, 4)

     b = b.substring(0, 4)

end sub

If the variable first equals "Barak" and the variable last equals "Obama", then what are their values after the following subroutine call?

call Concat(first, last)

 

 

Instructions:

  1. Create a new project called subswap
  2. Add the following to the project form:
    1. Four text boxes
    2. Two buttons
  3. In your program create two subroutines.
    1. The first is called swap. It takes two parameters declared ByVal.
    2. The second is called flip. It also takes  two parameters, but these parameters are declared ByRef. Both subroutines swap their parameters.
  4. Program the first button to call swap twice with a pair of text boxes.
  5. Program the second button to call flip twice with a pair of text boxes.

Grading

Feature  Points  Out of  Notes 
Form     
swap subroutine     
flip subroutine   2  
Button programming   2  
Total   7  

 

Notes

 
 
 
 
 
 

 

 

Comments (0)

You don't have permission to comment on this page.