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
Solved

Array Columns

Posted on 2000-03-01
2
143 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 73
Adding to a VBA? 6 77
VB6 ListBox Question 4 48
Export PDF Form fields to Access  or Excel  in Tab order 16 78
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
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…
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…

840 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