I get the following error:
Comma, ‘)’, or a valid expression continuation expected
on the following piece of code:
Dim listOfMultipliers As New List(Of Double)
For i = 0.2 To 1.5 Step 0.1
listOfMultipliers.Add(i)
Next
Dim multipliersArray() As Double = listOfMultipliers.ToArray()
myarrey = multipliersArray
The error is on the first line and underscores ‘double’. I can’t figure out what the problem is. I searched the internet but couldn’t find an solution. Is it the case that i am using visual basic 2003 and this code is for an higher framework?
The example you have given is already valid, but it uses .NET Generics (i.e. the ability to specify a
List(Of Double)rather than just anArrayListthat acceptsObjects), which was not added to the .NET framework until version 2.0. .NET 2.0 was first supported by VB.NET version 8.0, which was included in Visual Studio 2005.The code you’re trying to write won’t work on VB2003. Is there a reason you can’t use a newer framework? (using Visual Basic 2010 Express, for instance, which is free)
If you’re stuck with 2003, you’ll have to use
ArrayList, and cast the items you take out of the list back to aDouble.