错误消息“使用新关键字创建对象实例”
我一直在 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
I keep having error message at ArrayGroup(count).dateDate = valueListString(0)
, have no idea what's wrong with the code below, please help.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ArrayGroup
是Nothing
。该行
不会为 ArrayGroup 赋值,因此它不会被实例化,当您尝试使用它时,您会收到正常的块错误。
您可能想将函数的结尾更改为类似的内容。
请注意
ReDim
。我不确定您是否需要As
。ArrayGroup
isNothing
.the line
does not assign a value to
ArrayGroup
so it is not instantiated and you'll get the normal with block error when you try to use it.you probably want to change the end of your function to something like.
Note the
ReDim
. I'm not sure if you need theAs
.ArrayGroup 中可能确实有项目。
所以在行
ArrayGroup(count).dateDate = valueListString(0)
之前尝试添加到数组the ArrayGroup probably does actually have items in it.
so before the line
ArrayGroup(count).dateDate = valueListString(0)
try adding to the array您似乎没有确定数组的尺寸:
尝试
查看
ReDim
和ReDim Preserve
只是声明 ArrayGroup 是一个 dataAttribute 类型的数组,但没有指定其中有多少个成员。
It does not appear that you have dimensioned you array:
Try
Have a look at
ReDim
andReDim Preserve
Just declares that ArrayGroup is an array of type dataAttribute but does not specify how many members are in it.