Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Type Arrays

Posted on 2004-03-25
4
Medium Priority
?
174 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

885 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