Solved

Type Arrays

Posted on 2004-03-25
4
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month3 days, 11 hours left to enroll

630 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