The program has a button named INCREMENT . The label that starts with 0 will increment every time the button is being pressed and save it in a database then so on. . .those being saved in the database will appear in MSFlexGrid.

Important part:
in MSFlexGrid
1
2
3
4
5
6

if the number 4 being deleted. . .it will look like this in MSFlexGrid:
1
2
3

5
6

if i press the button "RE-ARRANGE" it will look like this:
1
2
3
5
6

if i press the button "INCREMENT" it will not go directly to seven but instead the number 4 will be inserted:
1
2
3
5
6
4
press re-arrange:
1
2
3
4
5
6 and so on
7
8
9
10

this is a challenging one so pls help me. . i need to know how to do this. thank you so much.

## All 5 Replies

Hi,

Try the below coding,

``````Option Base 1 'Set Index of Array start with 0 or 1Dim i As Integer
Dim b() As Integer ' Array Variable
Dim Rearrange As Boolean
'To Delete the Selected row in the gridPrivate Sub cmdDelete_Click()
msflxgrid.TextMatrix(msflxgrid.RowSel, 0) = ""
End Sub
'To Increment the values
Private Sub cmdIncrement_Click()
Dim m As Integer
'Add new row in the gridmsflxgrid.Rows = msflxgrid.Rows + 1
' If Reaarange is true then only it will go into the process otherwise it will increment the value continuouslyIf Rearrange = True Then
'Loop process    For j = 1 To UBound(b)
'Check whether J+1 is lesser than or equal to the b array size
If j + 1 <= UBound(b) Then
'Check whether Current and Next array value is greater than 1
'If the value is greater than 1 then increment the current array value.            If Abs(b(j) - b(j + 1)) > 1 Then
msflxgrid.TextMatrix(msflxgrid.Rows - 1, 0) = b(j) + 1
m = 0
Exit For
Else
m = 1
End If
End If
Next
Else
'Continuous Increment
i = i + 1
msflxgrid.TextMatrix(i, 0) = i
End If
If m = 1 Then
'Continuous Increment    i = i + 1
msflxgrid.TextMatrix(msflxgrid.Rows - 1, 0) = i
End If
m = 0
End Sub
'Re - Arrange the Values in the gridPrivate Sub cmdReArrange_Click()
Dim j, k, l As Integer
Erase b
l = 1
Rearrange = True
'Set the size of the ArrayReDim Preserve b(1)
'Store the values from the grid to Array variableFor j = 1 To msflxgrid.Rows - 1
If msflxgrid.TextMatrix(j, 0) <> "" Then
ReDim Preserve b(UBound(b) + 1)
b(l) = msflxgrid.TextMatrix(j, 0)
l = l + 1
End If
Next
'Arrange the values in order
For j = 1 To UBound(b)
For k = 1 To UBound(b)
If b(k) > b(j) Then
l = b(j)
b(j) = b(k)
b(k) = l
End If
Next
Next
'Finally assign the values to the gridmsflxgrid.Rows = 1
For j = 1 To UBound(b)
If b(j) > 0 Then
msflxgrid.Rows = msflxgrid.Rows + 1
msflxgrid.TextMatrix(msflxgrid.Rows - 1, 0) = b(j)
End If
Next
End Sub``````

Shailaja:)

The program has a button named INCREMENT . The label that starts with 0 will increment every time the button is being pressed and save it in a database then so on. . .those being saved in the database will appear in MSFlexGrid.

Important part:
in MSFlexGrid
1
2
3
4
5
6

if the number 4 being deleted. . .it will look like this in MSFlexGrid:
1
2
3

5
6

if i press the button "RE-ARRANGE" it will look like this:
1
2
3
5
6

if i press the button "INCREMENT" it will not go directly to seven but instead the number 4 will be inserted:
1
2
3
5
6
4
press re-arrange:
1
2
3
4
5
6 and so on
7
8
9
10

this is a challenging one so pls help me. . i need to know how to do this. thank you so much.

Hi,

You want code for Increment or what..?

If you already have code for that, then,
Call Re-Arrange Code in Increment Click button...

Regards
Veena

Hi,

You want code for Increment or what..?

If you already have code for that, then,
Call Re-Arrange Code in Increment Click button...

Regards
Veena

I need the whole code. . it would be better if you include the increment code so it is easy to trace. . .

Hi,

Download the attached file and test it.

Shailaja:)

I need the whole code. . it would be better if you include the increment code so it is easy to trace. . .

commented: WOW. . .YOUR PROGRAM IS COOL. . IS NOW SOLVED. . .THANK YOU SO MUCH +1

Hi,

Download the attached file and test it.

Shailaja:)

hallo, I am studying the program you gave me. . .I'll let you know soon the result. . by the way, this that really you in the pic?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.