Solved

creating matricies

Posted on 1998-10-27
2
139 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
[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 18

Accepted Solution

by:
deighton earned 50 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

739 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