Results 1 to 4 of 4

Thread: [RESOLVED] MsFlexGrid value placed in textbox ?

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2009
    Posts
    46

    Resolved [RESOLVED] MsFlexGrid value placed in textbox ?

    Can anyone tell me how to place a value from an MsFlexGrid location into a Textbox upon program startup.

    I have an Access database file that fills the flexgrid with data.

    I then want the program to randomly pick a Row and Col from the flexgrid to display in the textbox at startup.

    Thanx,
    Bob K.

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: MsFlexGrid value placed in textbox ?

    u can get the cell value to the textbox like this
    Code:
    Text1.Text = MSFlexGrid1.Clip
    edit: u can try something like this
    Code:
    Text1.Text = MSFlexGrid1.TextMatrix(1, 1)
    u can select randomly the row,col values by random function, hope u got it, if not u can feel free to ask
    Last edited by seenu_1st; Oct 5th, 2009 at 12:04 AM.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2009
    Posts
    46

    Re: MsFlexGrid value placed in textbox ?

    edit: u can try something like this
    Code:
    Text1.Text = MSFlexGrid1.TextMatrix(1, 1)
    u can select randomly the row,col values by random function, hope u got it, if not u can feel free to ask
    seenu_1st,
    I tested this example you gave by placing different values for the row/col, like
    Code:
    Text1.Text = MSFlexGrid1.TextMatrix(10,1)
    and
    Code:
    Text1.Text = MSFlexGrid1.TextMatrix(3,2)
    worked fine except that the cell that was placed in the text box replaced the cell value at (1,1) each time.

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: MsFlexGrid value placed in textbox ?

    try this code, hope this is wat u want, add a msflexgrid, textbox and command button
    Code:
    Dim i, j As Integer
    
    Private Sub Command1_Click()
    Randomize
    i = Int(Rnd * 5) 'random number between 0 to 4
    j = Int(Rnd * 5) 'random number between 0 to 4
    Text1.Text = MSFlexGrid1.TextMatrix(i, j)
    End Sub
    
    Private Sub Form_Load()
    MSFlexGrid1.FixedCols = 0
    MSFlexGrid1.FixedRows = 0
    MSFlexGrid1.Cols = 5
    MSFlexGrid1.Rows = 5
    For i = 0 To 4
        For j = 0 To 4
            MSFlexGrid1.TextMatrix(i, j) = i & "," & j
        Next
    Next
    End Sub
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width