更新时间:2021-12-26 22:45:56
Split
怎么了?!
strListValues() = row.Item("ListValues").ToString.Split(",")
顺便说一句,出现的错误是因为您使用的是未初始化的strListValues
.
您需要在需要时使用strListValues(length)
或Redim
.
BTW, error you are getting is because you are using strListValues
un-initialised.
You need to use strListValues(length)
or Redim
it as and when required.
拆分没问题!
对Prerak正确答案的一个小改进.可以允许更宽松的输入格式:
Nothing''s wrong with split!
A minor improvement to the correct Answer by Prerak. Could allow a bit more relaxed input format:
strListValues[] = row.Item("ListValues").ToString().Split(
new char[] {',', ' '},
System.StringSplitOptions.RemoveEmptyEntries);
并且顺便说一下,摆脱所有那些立即数常量(硬编码),例如"ListValues
".
And, by the way, get rid of all those immediate constants (hard-coded), like "ListValues
".
您也可以使用以上答案.
仍然要使用相同的一个.
You can use above answer also.
Still you want to go with the same one use this.
Select Case (strChar)
Case ","
''GET SUBSTRING IN ARRAY
ReDim strListValues(intCount1)
strListValues(intCount) = Convert.ToString(row.Item("ListValues").ToString).Substring(intStart, strPos)
intStart = strChar + 1
intCount = intCount + 1
End Select
因为您没有初始化字符串数组的长度.
Because you did not initialize the length of string array.