I have a problem in sorting my line numbers.
My codes output like this
(801;802;803;804;805;806;807;808-814(1);808-814(2);815;;;;;;;;;;;;;;;;;840)
and its delimiter will loop until 840.
Dim sqlline As DataTable = MyDB.ExecCommand("SELECT `Line Number` from `" + cboJob.Text + "` WHERE `Orig Document Begin ID`='" + mData.Rows(z).Item(0).ToString.Trim + "' ORDER BY `Line Number`", "wellsfargo").Tables(0)
For q As Integer = 0 To sqlline.Rows.Count - 1
If sqlline.Rows.Count <> 0 Then
If q = 0 Then
lNum = sqlline.Rows(q).Item(0).ToString
Else
lNum += IIf(dZ.Rows(q).Item(13).ToString <> "", ";" + sqlline.Rows(q).Item(0).ToString, ";")
End If
'lNum += IIf(sqlline.Rows(q).Item(0).ToString <> "", ";" + sqlline.Rows(q).Item(0).ToString, "")
End If
Next
But I want my output will be like this.
(801;802;803;804;805;806;807;815;;;;;;;;;;;;;;;;;;;;;840;808-814(1);808-814(2))
so all the line numbers will be at the end.
now.. EDIT
I have this codes for me to put blanks delimiter at the end of the singe line number:
Dim sCont As String = ""
If dZ.Rows.Count < 40 Then
Dim iCont As Integer = 40 - dZ.Rows.Count
For c As Integer = 0 To iCont - 1
If c = 0 Then
sCont = ";"
Else
sCont += ";"
End If
Next
'Loop then Concatinate strings for each field value.
ElseIf dZ.Rows.Count = 40 Then
'Loop as is...
End If
Dim sVal As String()
If dZ.Rows.Count < 40 Then
sVal = (OrgDocbeg + "■" + _
OrgDocend + "■" + _
BEGDOC + "■" + _
ENDDOC + "■" + _
LoanNum + "■" + _
PCount + "■" + _
Path + "■" + _
FNum + "■" + _
sDate + "■" + _
StrConv(LNF, VbStrConv.ProperCase) + "■" + _
lNum + sCont + "■" + _
sDesc + sCont + "■" + _
StrConv(Amount, VbStrConv.ProperCase).Replace("Poc", "POC").Replace(".00.00", "") + sCont + "■" + _
sPay.Replace("^", "").Replace(" Of ", " of ").Replace(" And ", " and ").Replace(" And/or", " and/or").Replace(" By ", " by ").Replace(" 2Nd ", " 2nd ").Replace(" 3Rd ", " 3rd ") + sCont + "■" + _
sBorrow.Replace("$.00", "$0.00") + sCont + "■" + _
sSell + sCont + "■" + _
ProsBor + sCont + "■" + _
ProSell + sCont).Split("■")
Else
sVal = (OrgDocbeg + "■" + _
OrgDocend + "■" + _
BEGDOC + "■" + _
ENDDOC + "■" + _
LoanNum + "■" + _
PCount + "■" + _
Path + "■" + _
FNum + "■" + _
sDate + "■" + _
StrConv(LNF, VbStrConv.ProperCase) + "■" + _
lNum + "■" + _
sDesc + "■" + _
sPay.Replace("^", "").Replace(" Of ", " of ").Replace(" And ", " and ").Replace(" And/or", " and/or").Replace(" By ", " by ").Replace(" 2Nd ", " 2nd ").Replace(" 3Rd ", " 3rd ") + "■" + _
StrConv(Amount, VbStrConv.ProperCase).Replace("Poc", "POC").Replace("$.", "$0.") + "■" + _
sBorrow.Replace("$.", "$0.") + "■" + _
sSell.Replace("$.", "$0.") + "■" + _
ProsBor.Replace("$.", "$0.") + "■" + _
ProSell.Replace("$.", "$0.")).Split("■")
End If
But my output is wrong:
801;802;803;804;;;;;;;;808 - 817(1);808 - 817(2);808 - 817(3);808 - 817(4);808 - 817(5);808 - 817(6);;;;;;;;;;;;;;;;;;;;;;;
the output should be like this if I have ranges in the line number (must have delimiter until 840)
801;802;803;804;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;808 - 817(1);808 - 817(2);808 - 817(3);808 - 817(4);808 - 817(5);808 - 817(6)
but if I dont have ranges the correct output will be
801;802;803;804
If your line codes have fixed length then you can split resultsets based on the length, sort them independently and then combine them with
UNION ALL: