by Dinesh Thakur Category: Array

Consider the eight scout troops and their ticket sales. Now the groups are not numbered 1 to 8, but 101,103,110,115,121,123,130 and 145.

The group number and the number of tickets sold are still input, and the number of tickets must be added to the correct total. But now we must do one more step – determine to which array element to add the ticket sales, using a table lookup.

 

The first step in the project is to establish a user-defined type with the group numbers and totals and the dimension an array of the new type. Before, any processing is done, load the group numbers into the table.

 

Place the following statements in the general declaration section of a form module:

 

Private Type GroupInfo

intNumber as Integer

intTotal as Integer

End Type

 

Dim mudtGroup(1 to 8) as GroupInfo

 

Then initialize the values of the array element by placing these statements into the form_load procedure:

mudtGroup(1).intNumber = 101

mudtGroup(1).intNumber = 103

mudtGroup(1).intNumber = 110

etc.

 

During the program execution the user still enters the group number and the number of tickets sold into textboxes. The technique used to find the subscript is called a table lookup.

 

 



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.