Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

creating matricies

Posted on 1998-10-27
2
Medium Priority
?
144 Views
Last Modified: 2010-04-30
I want to create a nxn matrix of integers so I do:
dim A(n,n) as integer
now I want to be able to enter values row by row like:
A(1) = Array(1,2,3,4,5,6,7,8...)
A(2) = Array(2,3,4,5,6,7,8,9...)
The command above doesn't work, but is there one that does?
0
Comment
Question by:BoB
2 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 200 total points
ID: 1441785
'Heres a quick function I've written

Private Function LoadMatrix(Matrix() As Integer, iRow As Long, ByVal sValues As String)

    Dim sTemp As String
    Dim iL As Long
    Dim iVal As Long
   
       
    While sValues <> ""
   
        iVal = InStr(sValues, ",")
        If iVal = 0 Then iVal = Len(sValues) Else iVal = iVal - 1
               
        iL = iL + 1
       
        Matrix(iRow, iL) = CInt(Left(sValues, iVal))
       
        sValues = Mid(sValues, iVal + 2)
       
    Wend
   
End Function

'Example

Private Sub Command1_Click()

    Dim m(5, 5) As Integer

    Call LoadMatrix(m(), 1, "1,2,3,4,5")
   
    For c = 1 To 5
        MsgBox CStr(m(1, c))
       
    Next

End Sub



0
 

Author Comment

by:BoB
ID: 1441786
very nice, thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

916 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