Solved

Type Arrays

Posted on 2004-03-25
4
163 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
Comment Utility
'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
Comment Utility
sorry, i did not read your question till the end... and i don't understand the end...
0
 

Author Comment

by:jadeia
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now