Solved

creating matricies

Posted on 1998-10-27
2
135 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 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now