声明为结构成员的数组不能使用初始大小声明 [英] Arrays declared as structure members cannot be declared with an initial size
本文介绍了声明为结构成员的数组不能使用初始大小声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在VB6中有以下代码。如何在Visual Studios 2012中重新编写此内容?
如下所示,我收到以下错误消息:
声明为结构成员的数组不能用初始大小声明。
我见过可能的选择如何写这个但我无法工作。
I have the following code in VB6. How can I re-write this in Visual Studios 2012?
As it is written below, I get the following error message:
"Arrays declared as structure members cannot be declared with an initial size. "
I''ve seen possible alternatives to how this should be written but I cant get anything to work.
Structure selectStruct
Dim name As String 'name of menu
Dim options(0 To 300) As String 'the options in the select/combo
Dim selected As Integer 'the number of the option which is selected
Dim size As Integer 'number of options in menu
Dim node As IHTMLDOMNode ' the node in the DOM
End Structure
谢谢
thanks
推荐答案
请阅读我的评论。您没有提供足够的信息来发布确切答案。
VB6与VB.NET [ ^ ] - 有类似的语言都不一样。
数组class(VB.NET) [ ^ ]
我建议你使用自定义类。请按照以下链接:在Visual Basic .NET中使用类和结构 [ ^ 。我会分享一个例子,但我不知道你如何使用上面的数组......
Please, read my comment. You did not provide enough information to post exact answer.
VB6 vs. VB.NET[^] - there are similar languages both not the same.
Array class (VB.NET)[^]
I would suggest you to use custom class. Please, follow this link: Using Classes and Structures in Visual Basic .NET[^]. I''ll share an example, but i don''t know how do you use above array...
请参阅: http://msdn.microsoft.com/en-us/library/tey4z3ca%28v=vs.110%29.aspx [ ^ ]。
-SA
这是否有效:
Does this work:
Structure selectStruct
Dim options() As String
Sub New(ByVal size As Integer)
ReDim options(size - 1)
End Sub
End Structure
请注意,我使用size - 1因为我''猜猜原始代码应该说选项(0到299)。
Note that I used "size - 1" because I''m guessing the original code should say "options(0 To 299)".
这篇关于声明为结构成员的数组不能使用初始大小声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文