Hey, I'm using the following code to filter an msflexgrid to only display
rows with the entry "East Cork" in the 8th column. The table has many more entries, so, when I run the application, many rows are left blank. How can I get rid of these rows ? Here's my code, thanks in advance
Private Sub Form_Load()
MSFlexGrid1.AllowUserResizing = flexResizeColumns
MSFlexGrid1.SelectionMode = flexSelectionByRow
MSFlexGrid1.TextMatrix(0, 0) = "ID"
MSFlexGrid1.TextMatrix(0, 1) = "Customer"
MSFlexGrid1.TextMatrix(0, 2) = "Pickup Name"
MSFlexGrid1.TextMatrix(0, 3) = "Pickup Address"
MSFlexGrid1.TextMatrix(0, 4) = "Pickup Area"
MSFlexGrid1.TextMatrix(0, 5) = "Telephone Number(s)"
MSFlexGrid1.TextMatrix(0, 6) = "Delivery Name"
MSFlexGrid1.TextMatrix(0, 7) = "Delivery Address"
MSFlexGrid1.TextMatrix(0, 8) = "Destination Area"
MSFlexGrid1.TextMatrix(0, 9) = "Telephone Numbers(s)"
MSFlexGrid1.TextMatrix(0, 10) = "Weight of Package (in kg)"
MSFlexGrid1.TextMatrix(0, 11) = "Delivery Price"
MSFlexGrid1.TextMatrix(0, 12) = "Pickup Date"
MSFlexGrid1.TextMatrix(0, 13) = "Delivery Date"
MSFlexGrid1.TextMatrix(0, 14) = "Priority"
MSFlexGrid1.ColWidth(0) = 2000
MSFlexGrid1.ColWidth(1) = 2500
MSFlexGrid1.ColWidth(2) = 2500
MSFlexGrid1.ColWidth(3) = 2750
MSFlexGrid1.ColWidth(4) = 2500
MSFlexGrid1.ColWidth(5) = 2500
MSFlexGrid1.ColWidth(6) = 2500
MSFlexGrid1.ColWidth(7) = 2750
MSFlexGrid1.ColWidth(8) = 2500
MSFlexGrid1.ColWidth(9) = 2500
MSFlexGrid1.ColWidth(10) = 2500
MSFlexGrid1.ColWidth(8) = 2500
MSFlexGrid1.ColWidth(9) = 2500
MSFlexGrid1.ColWidth(10) = 2500
MSFlexGrid1.ColWidth(11) = 2500
MSFlexGrid1.ColWidth(12) = 2500
MSFlexGrid1.ColWidth(13) = 2500
MSFlexGrid1.ColWidth(14) = 2500
Open App.Path & "\deliveries.txt" For Input As #12
Dim oldRow As Long
Dim lngRow As Long
Dim lngCol As Long
Dim i As Long
Dim tRow As Long
Dim tCol As Long
Dim strID As String
MSFlexGrid1.Rows = 2
Do Until EOF(12)
Input #12, strID, strCustomer, strPickupName, strPickupAddress, strPickupArea, strPTelephoneNumbers, strDeliveryName, _
strDeliveryAddress, strDestinationArea, strDTelephoneNumbers, strWoP, strDeliveryPrice, _
strPickupDate, strDeliveryDate, strPriority
If frmLogin.cboLogin.Text = "Kevin" And strDestinationArea = "East Cork" Then
MSFlexGrid1.TextMatrix(1, 0) = strID
MSFlexGrid1.TextMatrix(1, 1) = strCustomer
MSFlexGrid1.TextMatrix(1, 2) = strPickupName
MSFlexGrid1.TextMatrix(1, 3) = strPickupAddress
MSFlexGrid1.TextMatrix(1, 4) = strPickupArea
MSFlexGrid1.TextMatrix(1, 5) = strPTelephoneNumbers
MSFlexGrid1.TextMatrix(1, 6) = strDeliveryName
MSFlexGrid1.TextMatrix(1, 7) = strDeliveryAddress
MSFlexGrid1.TextMatrix(1, 8) = strDestinationArea
MSFlexGrid1.TextMatrix(1, 9) = strDTelephoneNumbers
MSFlexGrid1.TextMatrix(1, 10) = strWoP
MSFlexGrid1.TextMatrix(1, 11) = strDeliveryPrice
MSFlexGrid1.TextMatrix(1, 12) = strPickupDate
MSFlexGrid1.TextMatrix(1, 13) = strDeliveryDate
MSFlexGrid1.TextMatrix(1, 14) = strPriority
End If
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
For lngRow = MSFlexGrid1.Rows - 2 To MSFlexGrid1.row Step -1
For lngCol = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.TextMatrix(lngRow + 1, lngCol) = MSFlexGrid1.TextMatrix(lngRow, lngCol)
If lngRow = MSFlexGrid1.row Then
MSFlexGrid1.TextMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next
i = 0
Loop
Close #12
Do While i < MSFlexGrid1.Rows
If MSFlexGrid1.TextMatrix(i, 0) = "" Then
MSFlexGrid1.RemoveItem i
End If
i = i + 1
Loop
MSFlexGrid1.Col = 13
MSFlexGrid1.Sort = flexSortStringAscending
For tRow = 1 To MSFlexGrid1.Rows - 1
MSFlexGrid1.row = tRow
If MSFlexGrid1.TextMatrix(tRow, 14) = "Low" Then
For tCol = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Col = tCol
MSFlexGrid1.CellBackColor = RGB(204, 255, 153)
Next
ElseIf MSFlexGrid1.TextMatrix(tRow, 14) = "Medium" Then
For tCol = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Col = tCol
MSFlexGrid1.CellBackColor = RGB(202, 225, 255)
Next
ElseIf MSFlexGrid1.TextMatrix(tRow, 14) = "High" Then
For tCol = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Col = tCol
MSFlexGrid1.CellBackColor = RGB(255, 228, 225)
Next
End If
Next
End Sub