Solved

MSFlexGrid: Want To Load arrays and variables

Posted on 2000-03-31
5
349 Views
Last Modified: 2012-05-04
I'm real new to VB and I'm working on an application where I have a 2 Column MSFlexGrid.  What I would like to do is load the 2nd Col with an array or a variable from a procedure.  I can "hard load" data in the grid but don't understand why I can't bring in data from variables.  The example Grid below is only 3 lines deep but in my procedure I need to display 101 lines.  I like the way MSFlexGrid displays the data but am not sure this is the way to go.  I've been stumped on this for a while and as I said earlier I'm just starting in VB.

Dim intLoadAddr00 as Integer
Dim intLoadAddr01 as Integer

Private Sub Form_Load()

    ' initialize grid
    With AddrGrid
        .Cols = 2
        .Rows = 3
        .ColWidth(0) = 500
        .ColWidth(1) = 1000
        .TextMatrix(0, 0) = "Addr"
        .TextMatrix(1, 0) = "0"
        .TextMatrix(2, 0) = "1"
 
        .TextMatrix(0, 1) = "CODE"
        .TextMatrix(1, 1) = intLoadAddr00
        .TextMatrix(2, 1) = intLoadAddr01

    End With
 
End Sub
0
Comment
Question by:mikepennst
[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
5 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2673041
In the MSFlexGrid you can set the .Row and the .Col properties and then simply set the .Text property to change the contents of the cell in question.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2673048
Check out this handy Flex Grid example ;-)

http://homepage.eircom.net/~carafa/VBSamples/VB5/MSFLEXGRID.zip
0
 
LVL 6

Accepted Solution

by:
VBGuru earned 100 total points
ID: 2673072
To add new row just say
MSFlexGrid.rows= MSFlexGrid.rows +1
To add new column to grid say
MSFlexGrid.cols = MSFlexGrid.cols + 1

to refer to a cell just say
which column that cell belongsusing the property
MSFlexGrid.Col=1(1st column)
and the row by MSFlexGrid.Row = 1(1st row)
then manuplate the content MSFlexGrid.Text = "New Content"

Thats it very simple
0
 
LVL 6

Expert Comment

by:Marine
ID: 2673203
When using .TextMatrix property you can interprit it as an 2 dimentional array, Cols,Rows. Having that you can bring your procedure and populate it.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2673230
To load you Flexgrid.. try this (assuming you have VB6).. With your MSFlexgrid empty, then use the Additems method to populate your rows. In the array statement you can use variables or constants, whicever you require.

Dim varTable as variant
varTable = Array(strColumn1_Data, strColumn2_Data, intColumn3_Data, "etc")
MSFlexGrid1.AddItem Join(varTable, vbTab) ' Row 0 Space
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
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…

752 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