Solved

Array Columns

Posted on 2000-03-01
2
146 Views
Last Modified: 2010-05-02
How do you make an array show as a table? Mine show up as

Peas
1.00
10
Jam
2.00
5
I want it to look like this:

Sampl:
Name Cost code
Peas 1.00 P
Jam  2.00 J

0
Comment
Question by:mad3654
[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 Comments
 
LVL 2

Accepted Solution

by:
alokanant earned 30 total points
ID: 2575208
hi mad3654,
here is the code -

Dim a(6) As Variant
    Dim i As Integer
   
    a(0) = "JIM"
    a(1) = "100"
    a(2) = "C"
    a(3) = "TIM"
    a(4) = "200"
    a(5) = "D"
   
    Open "C:\ALOKTEMP\TESTFILE" For Output As #1
    i = 0
    Print #1, "Name Cost Code"
    While i < UBound(a)
        Print #1, a(i); "   "; a(i + 1); "   "; a(i + 2)
        i = i + 3
    Wend

hth
alok
0
 

Expert Comment

by:ramaswamy_ravi
ID: 2575223
mad3654 ,
Method 1
========
Dim I%, J%
Dim X(0 TO 6) As String
Dim Y(0 To 1, 0 To 1, 0 To 1) As String
For I = 0 To 5 Step 3
  J = J + 1
  X(J, 0, 0) = Y(I)
  X(J, 0, 1) = Y(I + 1)
  X(J, 1, 0) = Y(I + 2)
Next I

Method 2
========
Type TYPE_X
 strName As String
 sglCost As Single
 strCode As String
End Type

Dim Item(0 To 1) As TYPE_X

For I = 0 To 5 Step 3
  J = J + 1
  With Item(J)
    .strName = X(I)
    .sglCost = X(I + 1)
    .strCode = X(I + 2)
  End With
Next I

I prefer method 2 since you are not dealing with multi-dim arrays.

Hope this answers your question. If so, please convert this as an answer.

Please let me know.

Cheers,
Ravi
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

617 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