Solved

Type Arrays

Posted on 2004-03-25
4
167 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

Industry Leaders: 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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

679 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