VB.NET中的动态字符串数组 [英] Dynamic string array in VB.NET

查看:656
本文介绍了VB.NET中的动态字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要在下面动态拆分



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

推荐答案

如果你想每次都获得第一列,那么在我看来,你必须先检查我是否第一次归零,然后相应地移动:

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.:
i=i+4
Next



当i从0开始时,它将采取:KM51124844G01作为一个值

当你指定i = i + 4然后我将计算数组中的另外4个位置取决于数组有多少项。对于4个位置后的第二个组件,它将具有KM400740009G02作为值。再次......重要的是要提到这只适用于每一行:


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|



阵列每线预留4个值。



我真的希望这能帮到你!


the array is reserve 4 values per line.

I really hope this will help you!


这篇关于VB.NET中的动态字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆