Visual
Basic™ Framework
|
Software
|
[ Previous ] [ Basic Topics Index ] [ Next ]
How to transfer
value from one object to another object
1. Add event procedures for the objects. Type the following codes for ‘Keypress’ procedure on the object ‘Overtime’, and for ‘Click’ procedure on the ‘employee’ object. You may copy and paste only the bolded codes to the respective object and procedure.
|
Object: ‘Overtime’ - Procedure ‘KeyPress’ |
|
Private Sub Overtime_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Salary <>
"" Or Overtime <> "" Then Paycheque =
Val(Salary) + Val(Overtime) * 5 End If End If End Sub |
|
Object: ‘employee’ - Procedure ‘Click’ |
|
Sub
employee_Click() If employee.ListIndex <> -1 Then Salary = employee_info(employee.ListIndex, 1) Designation = employee_info(employee.ListIndex, 2) If Val(Overtime) <> 0 Then Paycheque = Salary Else Paycheque = Salary + Val(Overtime) * 5 End If End If End Sub |
2. Add a ‘Quit’ command button to the form.
|
|
Details on how to add a button. You may skip this tip if you know how to create button. |
3. Test
your program by clicking the Run icon
on the Toolbar or selecting ‘Start’ from the
Run menu. If any errors occur, correct
them and start again.
4. To
stop the program, click the End icon
or select ‘End’ from the Run menu.
|
|
At this check point, record Second Quarter Completion Time: _____________ |
Complete your program like any other Visual Basic applications by adding a start-up page to the program.
Last revised: 30 January 2004 15:00
If you spot an error, please contact sbho@mmu.edu.my In addition, please contact me if you find some aspects of this task is not explained clearly so that I can improve this documentation.