While Not sr.EndOfStream
line = sr.ReadLine
If line.Contains("Year") Then
currentYear = line.ToString
ElseIf line.Contains("mandatory") Then
moduleStats = "M"
ElseIf line.Contains("optional") Then
moduleStats = "O"
ElseIf line.Contains("COM") Then
modArray = line.Split(",")
Dim i As Integer = modArray.Length
ReDim Preserve modArray(modArray.Length + 2) 'ReDim statement to change the size of one or more dimensions of an array,
'Preserve you can resize that dimension and still preserve all the contents of the array
modArray(i) = moduleStats
modArray(i + 1) = currentYear.ToString()
MsgBox(String.Join(",", modArray))
这是我的代码,当我在消息框中查看数组时,它在每个数组元素的末尾都包含一个逗号,这是我不想知道的是我如何为每个元素修剪它?感谢
答案 0 :(得分:1)
您的ReDim
添加了太多的元素。
这会导致Join
有额外的,
。
将其更改为:
ReDim Preserve modArray(modArray.Length + 1)