Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
need to split dynamically below mention

KM51124844G01| 1.000 PC|FLAT CABLE FIXING ASSY,IMC SLING|1001.47|
|KM400740009G02|2.000 PC|OIL COLLECTOR &GUIDE LUBRICATOR|93.02|
|KM400740009G01|2.000 PC|GUIDE RAIL LUBRICATOR & OIL COLLECTOR| 113.42|


What I have tried:

 dt = objdbconn.GetDatatable(msSQL)
            For Each dr As DataRow In dt.Rows
                Dim datalist As String = dr.Item("assembly_list").ToString
                Dim strarr() As String = datalist.Split(New String() {"|"c}, StringSplitOptions.None)
                Dim i As Integer = 0
                For Each col In strarr
                    Dim dat As String = strarr(i)
i=i+1
Next
Posted
Updated 3-Jul-17 1:29am
Comments
Patrice T 3-Jul-17 7:11am    
And you have a question or a problem ?

1 solution

If you want to get the first column everytime then in my opinion, you have to check whether i is equl to zero the first time and then move accordingly.:
VB
i=i+4
Next

When the i starts as 0, it is going to take : KM51124844G01 as a value
when you assign the i = i+4 then the i is going to count 4 more positions in the array depending on how many items the array has. For the second assembly after 4 positions it is going to have KM400740009G02 as a value. Again.... it is important to mention that this will only work only if for each Line:
KM51124844G01| 1.000 PC|FLAT CABLE FIXING ASSY,IMC SLING|1001.47|

the array is reserve 4 values per line.

I really hope this will help you!
 
Share this answer
 
Comments
Gokulprasad05 3-Jul-17 23:40pm    
i want to took all the values.
Gokulprasad05 4-Jul-17 4:29am    
i got the answer...

If strarr.Length <= 5 Then
dcode = strarr(0)
dqty = strarr(1)
dunit = strarr(2)
dname = strarr(3)
dprice = strarr(4)
Else
Dim i As Integer = 1
For i = i - 1 To strarr.Length - 1
dcode = strarr(i)
dqty = strarr(i + 1)
dunit = strarr(i + 2)
dname = strarr(i + 3)
dprice = strarr(i + 4)
i = i + 4
Next
End If
Prifti Constantine 4-Jul-17 4:30am    
Nice! Sorry for not replying sooner.. Have been really busy!
Gokulprasad05 4-Jul-17 7:36am    
it's ok no problem. thanks for help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900