Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB6 number of the row dbclick

Posted on 2013-06-16
4
Medium Priority
?
371 Views
Last Modified: 2013-06-16
Hello all

I have this macro below that transfer data into my form 8 when i double click in a specific cell in my MSHFlexgrid.

Now, i would like to add in a TEXT13 the row number from the grid.

Ex:

I f i double click in the 3rd row, it will put 3 in my TEXT13.

How can i do that?

Thanks again for your help



On Error GoTo handler
Form8.Show
Form8.Text0 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 3))
Form8.Text00 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 4))
Form8.Text3 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 9))
Form8.Text4 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 11))
Form8.Text5 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 12))
Form8.Text6 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 13))
Form8.Text7 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 15))
Form8.Text8 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 16))
Form8.Text9 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 17))
Form8.Text10 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 20)) '
Form8.Text11 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 21))
Form8.Text12 = Trim(Form3.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 23))

Exit Sub
handler:
MsgBox "Try again"

Open in new window

0
Comment
Question by:Wilder1626
[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
  • 2
4 Comments
 
LVL 30

Expert Comment

by:Randy Downs
ID: 39251210
Try this

http://vbcity.com/forums/t/23153.aspx

Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)

    Dim lngRow As Long
    Dim lngCol As Long
    Dim loop1 As Long
    Dim sngColRight As Single
    
    'make sure we're in column mode
    If ListView1.View = lvwReport Then
    
        'select the clicked row, using HitTest to return the clicked item
        Set ListView1.SelectedItem = ListView1.HitTest(30, y)
        'ensure that there is a row there
        If Not ListView1.SelectedItem Is Nothing Then
            'get the row number
            lngRow = ListView1.SelectedItem.Index
            
            'loop throught each column
            For loop1 = 1 To ListView1.ColumnHeaders.Count
                'add the column width to the value we're checking
                sngColRight = sngColRight + ListView1.ColumnHeaders(loop1).Width
                
                'if the X location is less the the total current column width
                If x <= sngColRight Then
                    'this is the column
                    lngCol = loop1
                    'exit the loop
                    Exit For
                End If
            Next
            
            
            'disply the information
            Label1.Caption = "Row = " & CStr(lngRow) & " Col = " & CStr(lngCol)
            
            'make sure that a row and column were found
            If lngRow <> 0 And lngCol <> 0 Then
                Label2.Caption = "Value clicked = "
                If lngCol = 1 Then
                    Label2.Caption = Label2.Caption & ListView1.SelectedItem.Text
                Else
                    Label2.Caption = Label2.Caption & ListView1.SelectedItem.SubItems(lngCol - 1)
                End If
            End If
        End If
    End If
End Sub

Open in new window

0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 39251357
Private Sub MSFlexGrid1_DblClick()
If MSFlexGrid1.Row = 2 Then
    Form8.Text12 = MSFlexGrid1.Row + 1
    ' Or just
    'Form8.Text12 = "3"
End If

End Sub

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 39251373
Hi,

this is perfect. Actually i will only use this and it work:
Form8.row_num = Form3.MSHFlexGrid1.Row

Thanks again
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39251394
You're welcome and I'm glad I was able to help.

Select the 'About Me' tab in my profile and you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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

609 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