Class Notes for 06/08/06
3,b How many times to loop
(using inputbox) exactly as Pg(68)
inputbox(“HOW MANY EMPLOYEES”)
Dim counter, n As Integer
counter = 1
n = InputBox("HOW MANY EMPLOEES")
While (counter <= n)
MsgBox("HELLO" & counter) ← note: This is the body to do 3.C.
counter = counter + 1
End While
MsgBox("BYE BYE " & n)
If you add the file it’ll become 3.B
Q5a) Run the following program. Briefly say in your own words what does it do?
Create a new project and use your name in the project title, save it on your Z: drive (your account). Create a text file called employees.txt and save it desktop or in the “bin” folder of your project. Enter data into your text file including the name and gross pay of employees in the following format:
Note: Andres represents employee name and 1000.00 is the grosspay
Andres
1000.00
John
500.00
Lina
750.00
Peter
456.00
Anna
670.00
Create a form similar to:

Double-click on the button to write the code:
Dim name As String
Dim grosspay As Double
Dim i As Integer
Dim fin As IO.StreamReader = IO.File.OpenText("employees.txt")
For i = 1 To 5
name = fin.ReadLine
grosspay = fin.ReadLine
If name = TextBox1.Text Then
TextBox2.Text = FormatCurrency(grosspay)
End If
Next
Fin means “FILE IN”
5b)Explain what this program does and how it works (e.g. what does the loop do, what does the If … Then statement do)
How to create a text file and write to a file
dim fout as Io.streamWriter = Io.File.CreateText("employee2.txt)
fout.writeline(textbox1.text)
fout.writeline(textbox2.text)
fout.close