Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Print an Array

Status
Not open for further replies.

SmokeEater

Technical User
Feb 14, 2002
90
CA
I have this code
Code:
Sub DisplayArray(InArray() As String)
  Dim i As Integer, j As Integer
  For i = LBound(InArray, 1) To UBound(InArray, 1)
    For j = LBound(InArray, 2) To UBound(InArray, 2)
      Debug.Print InArray(i, j),
    Next j
    Debug.Print
  Next i
End Sub
which very nicely prints my array in the immediate window. My problem is that I would like to print this array on a report. I'm stumped. Any help would be appreciated.
 
Why not set a textbox to the name of a function?

Code:
Function DisplayArray(InArray() As String)
  Dim i As Integer, j As Integer
  For i = LBound(InArray, 1) To UBound(InArray, 1)
    For j = LBound(InArray, 2) To UBound(InArray, 2)
      strText= strText & InArray(i, j),
    Next j
    Debug.Print
  Next i
DisplayArray=strText
End Function

Or there abouts.
 
The final code that works looks like this
Code:
Function DisplayArray(InArray() As String)
Dim mSTR
Dim mSTR1
  Dim j As Integer, k As Integer
  For j = LBound(InArray, 1) To UBound(InArray, 1)
    For k = LBound(InArray, 2) To UBound(InArray, 2)
      ' Debug.Print InArray(j, k),
        If InArray(j, k) = "" Then
            mSTR1 = " "
        Else
            mSTR1 = InArray(j, k)
        End If
       mSTR = mSTR & mSTR1
    Next k
     '  Debug.Print
    mSTR = mSTR & vbCrLf
  Next j
DisplayArray= mSTR
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top