| | |
Copy info from one form to another VB 6
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Dec 2007
Posts: 74
Reputation:
Solved Threads: 0
Hi
I am working on a payroll program which have 3 forms.
First form has three text box (First name, Surname, Total Hour) and one command button Calculate.
After the user put the info he/she will click calculate button and this will show the second form which display the (firstname, surname, Gross salary, netwage).
I do have another form called frmsummary this form should hold detail of up to 10 person, currently using the code bellow in form two when user click copy info command button on the second form I could only copy 1 person info to form 3. I don’t know what to do any help to get 10 people info coped?
Private Sub cmdcd_Click()
frmsummary.lblfname0 = frmWage.lblfirstname.Caption
frmsummary.lblsname0 = frmWage.lbllastname.Caption
frmsummary.lblgsalary = frmWage.lblGrossSalary.Caption
frmsummary.lblnwage = frmWage.lblNetWage.Caption
frmsummary.Show
End Sub
Thanks for your help in advance
HB25
I am working on a payroll program which have 3 forms.
First form has three text box (First name, Surname, Total Hour) and one command button Calculate.
After the user put the info he/she will click calculate button and this will show the second form which display the (firstname, surname, Gross salary, netwage).
I do have another form called frmsummary this form should hold detail of up to 10 person, currently using the code bellow in form two when user click copy info command button on the second form I could only copy 1 person info to form 3. I don’t know what to do any help to get 10 people info coped?
Private Sub cmdcd_Click()
frmsummary.lblfname0 = frmWage.lblfirstname.Caption
frmsummary.lblsname0 = frmWage.lbllastname.Caption
frmsummary.lblgsalary = frmWage.lblGrossSalary.Caption
frmsummary.lblnwage = frmWage.lblNetWage.Caption
frmsummary.Show
End Sub
Thanks for your help in advance
HB25
I would declare a Public Array of your own type: You can declare the amount in the array to begin with or assign the amount dynamically with a Redim statement.
Hank
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Public Type Employee Salary As Currency FirstName As String SurName As String HoursWorked As Single End Type Dim MyEmployees(10) As Employee
Hank
Last edited by hkdani; Dec 25th, 2007 at 6:20 pm.
You have to update the Array.
MyEmployees(0) Would be your first employee
MyEmployees(1) Would be your second employee, etc.
Using the different values in the array, you have separate storage area for each employee. Once you've stored the values corresponding to one member, it can be later accessed by remembering the Array Value.
Or you can even search the Array until you find the Name you're looking for using a loop.
MyEmployees(1).Name
MyEmployees(2).Name
MyEmployees(0) Would be your first employee
MyEmployees(1) Would be your second employee, etc.
Using the different values in the array, you have separate storage area for each employee. Once you've stored the values corresponding to one member, it can be later accessed by remembering the Array Value.
Or you can even search the Array until you find the Name you're looking for using a loop.
MyEmployees(1).Name
MyEmployees(2).Name
•
•
Join Date: Dec 2007
Posts: 74
Reputation:
Solved Threads: 0
hkdani you have been very helpful but you miss understand me I don’t have 10 emplyee what I have in frmsummary which is my last form does have 10 lable under first name, 10 lable under surname, 10 lable under Gross Salary and 10 lable under Netpay. I need these lables to be updated after user use from one “frminput” to input the info and then in form two “frmwagw” click on cmdcd( which is for copying the info in this form to frmsummary)
hope you understand above, I would like to send you the project but I don’t how to do that I wonder if accept I send you my email address
Thanks
hope you understand above, I would like to send you the project but I don’t how to do that I wonder if accept I send you my email address
Thanks
You can use the Public type as a means of storage. You might want to add a regular module (not a class module) to your product to declare it in that section as I mentioned before. You could also declare a Public Variable ArrayCounter for your array in the same module.
But you need to change the Array Counter as new employee information is entered for each different employee. As long as you don't close your program down, the information will remain in memory. I don't know how you determine when your done collecting your information, but at that point, if you're using the Public type Array, you should enter that information at that time:
Your first input form (frmInput) will copy the info into the Array.
Now you can use that info once its stored in the Public Type to copy into your other forms.
But you need to change the Array Counter as new employee information is entered for each different employee. As long as you don't close your program down, the information will remain in memory. I don't know how you determine when your done collecting your information, but at that point, if you're using the Public type Array, you should enter that information at that time:
Your first input form (frmInput) will copy the info into the Array.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub Update_Array() With MyEmployees(ArrayCounter) .FirstName = txtFirstName.text .SurName = txtSurName.text .HoursWorked = txtHoursWorked.text .SalaryRate = txtSalaryRate.text End with ' Update the counter for the next employee ArrayCounter= ArrayCounter + 1
Now you can use that info once its stored in the Public Type to copy into your other forms.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
With MyEmployees(ArrayCounter) frmwagw.labelEmp1Name = .FirstName frmwagw.labelEmp1Surname = .SurName ' etc. frmummary.labelEmp1Name = .FirstName frmummary.labelEmp1SurName = .SurName ' etc End with
Last edited by hkdani; Dec 25th, 2007 at 8:28 pm.
![]() |
Similar Threads
- Setting up a form in PHP (PHP)
- getting form elements to write to a file (Perl)
- User Form error checking (PHP)
- asp form action script (Site Layout and Usability)
- Excel Form - For/Next - Naming Convention Problem (Visual Basic 4 / 5 / 6)
- how to pass a form to another form (Visual Basic 4 / 5 / 6)
- Lost jpeg (Mac Software)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Opening several files one after another
- Next Thread: How to include Access and Crystal Report in Setup file
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





