Solved

MSFlexGrid: Want To Load arrays and variables

Posted on 2000-03-31
5
343 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

919 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

21 Experts available now in Live!

Get 1:1 Help Now