Solved

Type Arrays

Posted on 2004-03-25
4
165 Views
Last Modified: 2010-05-01
1) I'm having some problems with Type Arrays (mainly keeping a firm grasp on them in my mind while I code). This project is part of my college studies, so I'm looking for some suggestions on how to tackle this particular part. I've finished the algorithm in pseudocode, and it's is correct.

Part pseudocode for the function I am trying to code:

cmdOK_Click()

If all employees have been added to the Wages array
 - Show warning message
Else
 - Call SaveWagePayment()
 - Call cmdClearPayDet_Click()


My question is how exactly could you use a normal array to hold how many records have been added to a type array?

Example:

WageArray(1 to 10) - holds employees wage details defined as a type:
Private Type WAGE_RECORD_TYPE
    lngEmployeeId As Long
    intPayDate As Date
    sngHoursWorked As Single
End Type

intWagesAddedCount - holds how many employees have been added to the WageArray

Now how the heck do I use an integer array, to keep a check of what records have been added to the type array? I cant get my head around it just yet, and I thought I should rather use a boolean array, and could store TRUE or FALSE in the elements - but my lecturer tells me it should be an integer type.

Please go easy on me, VB student (aspiring VB expert one day).  I can post actual code if need be, but it's long.
0
Comment
Question by:jadeia
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
ennixo earned 500 total points
ID: 10679725
'simply declare your type
Private Type WAGE_RECORD_TYPE
    lngEmployeeId As Long
    intPayDate As Date
    sngHoursWorked As Single
End Type

'and your public array variable
Public WageArray(1 to 10) As WAGE_RECORD_TYPE
0
 
LVL 5

Expert Comment

by:ennixo
ID: 10679746
sorry, i did not read your question till the end... and i don't understand the end...
0
 

Author Comment

by:jadeia
ID: 10679828
I tried editing this question but as I submitted it had already been responded too.

My apologies, I misunderstood the problem. That's what I get for spending too long at it. Can a moderator remove this question?

The answer was simply the WagesAddedCount was a simple integer, NOT an integer Array...  I thought it didnt make sense.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 10680223
Why do you feel the need for a second array?  As ennixo's code sample demonstrates you define the type and then make an arry of that type.  If you don't use all the positions in the array, then you could test one of the fields to see if it's blank, or you could add a field, a boolean maybe, to indicate if a position is in use.  You could also make the array dynamic, adding/deleting records as needed by using redim preserve.  If you chose that approach, then you could simply check the number of records in the array using the ubound function.
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question