Avatar of josephdaviskcrm
josephdaviskcrmFlag for United States of America

asked on 

VB.NET - ArrayList copied over to a normal array

I have an arrayList that I'm trying to convert to an array.

Given that arrUnits is an array of strings...

Dim arrlistUnits As ArrayList = New ArrayList
Dim arrUnitsSub() As String
For i As Integer = arrUnits.GetLowerBound(0) To arrUnits.GetUpperBound(0)
   Database.Gather_Data_Store_Data_Table(GetSeriesSQL(arrUnits(i)), dt)
   If dt.Rows.Count <> 0 Then
      arrlistUnits.Add(arrUnits(i))
   End If
Next
arrlistUnits.CopyTo(arrUnitsSub)

So I'm trying to copy the resulting ArrayList into the array arrUnitsSub, but what I'm trying above apparently is not correct.
Visual Basic.NET

Avatar of undefined
Last Comment
josephdaviskcrm
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

do with:
Array.Resize(arrUnitsSub, arrlistUnits.Count)
arrlistUnits.CopyTo(arrUnitsSub)
 
Avatar of josephdaviskcrm

ASKER

The problem that I'm getting is an error saying that arrUnitsSub is being used before it is being assigned a value.
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of josephdaviskcrm

ASKER

Great, Thanks!  Thats exactly what I was looking for.  I was finding it hard to believe that a method didn't exist to for something that seemed so common.
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo