Solved

VB6 convert MSHFlexgrid1 cells no2

Posted on 2016-07-26
2
71 Views
Last Modified: 2016-07-27
Hi,

This topic follow the previous one on this link:
https://www.experts-exchange.com/questions/28959455/VB6-convert-MSHFlexgrid1-cells.html?anchor=a41728752#a41728752

I need to add 1 small thing to previous code when in column 4, i need to add a sequence number.

Just as a recap:
What i would like to do is that if i have multiple rows with the same value in column 0, 1 and 11, it will leave all cell populated  as it is and also add the letter "H" in column 3 of the first row only.
Then, it will empty the value in column 2 and add the letter "D" in column 2.

Now i want to add in column 4 the sequence number always matching column 0, 1 and 11 combination.

Ex:

Before:
before
After macro:
after_result
How can i do that?

Thanks for your help
Filter-grid.zip
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 Comments
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 41730689
Private Sub Command2_Click()
    Dim strOldKey As String
    Dim lngRow As Long
    Dim lngD As Long
    Dim lngStartRow As Long
    Dim intSeq As Integer
    
    strOldKey = MSHFlexGrid1.TextMatrix(1, 0) & MSHFlexGrid1.TextMatrix(1, 1) & MSHFlexGrid1.TextMatrix(1, 11)
    lngStartRow = 1
    intSeq = 1
    MSHFlexGrid1.TextMatrix(lngStartRow, 3) = "H"
    MSHFlexGrid1.TextMatrix(lngStartRow, 4) = intSeq
    
    For lngRow = 2 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngRow, 0) & MSHFlexGrid1.TextMatrix(lngRow, 1) & MSHFlexGrid1.TextMatrix(lngRow, 11) <> strOldKey Then
            MSHFlexGrid1.TextMatrix(lngRow, 3) = "H"
            intSeq = 1
            For lngD = lngStartRow + 1 To lngRow - 1
                MSHFlexGrid1.TextMatrix(lngD, 2) = ""
                MSHFlexGrid1.TextMatrix(lngD, 3) = "D"
                intSeq = intSeq + 1
                MSHFlexGrid1.TextMatrix(lngD, 4) = intSeq
            Next
            lngStartRow = lngRow
            strOldKey = MSHFlexGrid1.TextMatrix(lngStartRow, 0) & MSHFlexGrid1.TextMatrix(lngStartRow, 1) & MSHFlexGrid1.TextMatrix(lngStartRow, 11)
        End If
    Next
    intSeq = 1
    MSHFlexGrid1.TextMatrix(lngStartRow, 4) = intSeq
    For lngD = lngStartRow + 1 To lngRow - 1
        MSHFlexGrid1.TextMatrix(lngD, 2) = ""
        MSHFlexGrid1.TextMatrix(lngD, 3) = "D"
        intSeq = intSeq + 1
        MSHFlexGrid1.TextMatrix(lngD, 4) = intSeq
    Next
End Sub

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 41730988
And again, it does exactly what i wanted.
 Thank you again and again!!!!
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

730 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