Solved

MSFlexGrid: Want To Load arrays and variables

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 54
Advice in Xamarin 21 78
Zip Folders Using Chilkat Routines 1 36
Error with a code discussed on this page 5 12
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 …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

806 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