A
Anson
Dear All,
I'm a VB6 programmer migrating to VB.Net .
I have a question regarding the usage of Collection in VB.Net. The following
is the code i would use in VB6.
'************* VB6 Code ***************
Dim tempStr(2) as string
Dim tempCollection as new collection
for i = 1 to 10
tempstr(0) = cstr(i)
tempstr(1) = "XXX"
tempstr(2) = "YYY"
tempcollection.add tempstr
next i
'*************************************
This code works without any problem. However, if i use the same code in
VB.Net. The elements in the resultant collection are all the same (10, XXX,
YYY) , all equal to the value of the last element.
Do i somehow have to "new" the array of string? Does .Net take the string
array as an object? If so, how do i new a string?
Thank you in advance for your response.
Best Regards,
Anson
I'm a VB6 programmer migrating to VB.Net .
I have a question regarding the usage of Collection in VB.Net. The following
is the code i would use in VB6.
'************* VB6 Code ***************
Dim tempStr(2) as string
Dim tempCollection as new collection
for i = 1 to 10
tempstr(0) = cstr(i)
tempstr(1) = "XXX"
tempstr(2) = "YYY"
tempcollection.add tempstr
next i
'*************************************
This code works without any problem. However, if i use the same code in
VB.Net. The elements in the resultant collection are all the same (10, XXX,
YYY) , all equal to the value of the last element.
Do i somehow have to "new" the array of string? Does .Net take the string
array as an object? If so, how do i new a string?
Thank you in advance for your response.
Best Regards,
Anson