Click here to Skip to main content
15,849,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody,

I have a problem that need your help.
I have some code in VB6 as below:

Public Type Employ
    arrName(10) as String    
End Type

And Now I want to use them in VB.NET 2010 as following:
Public Structure Employ
    Dim arrName(10) as String    
End Structure

and VB.NET display error:
"Arrays declared as structure members cannot be declared with initial size"

do you have which Solution to initialize a size for array arrName the same in VB6

please help me.

Thanks in advance

This[^] covers the basics. Your problem is that you're doing it inside a struct. Which means, I believe, you need to do

Dim arrName() as String

and then set a size when you use it, with Redim. At least, that's what I find when I google that error message.
Share this answer
dear ngthtra,

I also think solution 1 is right, hope this example will help u.

Sub Main()
     Dim emp As Employ
     ReDim emp.arrName(4)
 End Sub
 Public Structure Employ
     Dim arrName() As String
 End Structure
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900