Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MSFlexGrid: Want To Load arrays and variables

Posted on 2000-03-31
5
Medium Priority
?
356 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 300 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 …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

715 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