我一直在ArrayGroup(count).dateDate = valueListString(0)
收到错误消息,不知道下面的代码有什么问题,请帮忙。
Structure dataAttribute
Dim dateDate As Date
Dim timeString As String
Dim volString As String
Dim openString As String
Dim closeString As String
Dim minString As String
Dim maxString As String
End Structure
Private ArrayGroup() As dataAttribute
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim currencyString As String
Dim valueListString() As String
currencyString = dataTextFieldParser.ReadToEnd
RichTextBox1.Text = currencyString
strArr = currencyString.Split(Environment.NewLine)
For count = 1 To strArr.Length - 1
valueListString = strArr(count).Split(";")
ArrayGroup(count).dateDate = valueListString(0)
ArrayGroup(count).timeString = valueListString(1)
Next
End Sub
答案 0 :(得分:0)
ArrayGroup可能确实包含了其中的项目。
所以在行ArrayGroup(count).dateDate = valueListString(0)
尝试添加到数组之前
ArrayGroup(count) = New ... what ever type should be in the array...
答案 1 :(得分:0)
您似乎没有确定数组的尺寸:
尝试
ReDim ArrayGroup(0)
查看ReDim
和ReDim Preserve
Private ArrayGroup() As dataAttribute
只是声明ArrayGroup是一个dataAttribute类型的数组,但是没有指定其中有多少成员。
答案 2 :(得分:0)
ArrayGroup
是Nothing
。
行
Private ArrayGroup() As dataAttribute
没有为ArrayGroup
赋值,因此它没有实例化,当你尝试使用它时,你会得到正常的块错误。
您可能希望将函数的结尾更改为类似的内容。
Redim ArrayGroup(strArr.Length - 1) As dataAttribute
For count = 1 To strArr.Length - 1
valueListString = strArr(count).Split(";")
ArrayGroup(count).dateDate = valueListString(0)
ArrayGroup(count).timeString = valueListString(1)
Next
End Sub
请注意ReDim
。我不确定您是否需要As
。