Can't declare lists in VB.NET?

18,773

Solution 1

Use Generic.List instead of just List.

Dim lstNum As New Generic.List(Of Integer)(New Integer() { 3, 6, 7, 9 })

Since you have the Word interop imported, it is trying to find Word.List. Specifying Generic.List will tell it to go outside of that import.

Solution 2

Try adding System.Collections.Generic

 Dim lstNum As New System.Collections.Generic.List(Of Integer)(New Integer() { 3, 6, 7, 9 })
Share:
18,773

Related videos on Youtube

redhotspike
Author by

redhotspike

Currently pursuing a Masters in Computer Science. Graduated from Tennessee Tech University with a Bachelor's in Computer Science with a concentration in Software & Scientific Applications. Currently working as a Computer Scientist, developing "whatever they give me." I have a strong background with Java & C/C++ as well as the "big" web-development languages. I did my first bit of coding at age 11 with a website. Instantly hooked. The rest is history. Previous professional coding experience includes working with: VC++.Net Microsoft's MVC Win32 Programming Win64 Programming Ada C++ Qt (vsn 3.x & vsn 4.x) C# (WPF) Java VB.Net SQL/MySql (I know they're different but I use both so I tend to say them interchangeably) PHP CSS HTML Operating System Experience includes: Windows (2000, XP, 7) Linux (RHEL, Redhawk, Ubuntu) Unix (MacOSx, Solaris)

Updated on June 25, 2022

Comments

  • redhotspike
    redhotspike almost 2 years
    Dim lstNum As New List(Of Integer)(New Integer() { 3, 6, 7, 9 })
    

    When I type the above line of code, Visual Studio informs me of an error

    'Microsoft.Office.Interop.Word.List' has no type parameters and so cannot have type arguments.

    What on earth does that mean and how do I fix it? I can't seem to create lists of any kind. I'm assuming I'm missing some sort of import but I'm not fluent with VB.Net enough to know what to try.

    • Kratz
      Kratz over 11 years
      You are not missing an import, it appears you have an extra one for Microsoft.Office.Interop.Word
    • ToolmakerSteve
      ToolmakerSteve over 10 years
      BTW, I bet you "do have imports declared", but don't realize it, because the "declaration" is in your VB Project's Properties, References tab, "Imported namespaces". That applies to ALL .vb files in your project. (I mention this, in case a future reader doesn't know they should look there.) Go there, UNCHECK Microsoft...Word. Then add Word ONLY to files that need it.
  • redhotspike
    redhotspike over 11 years
    THANKS! that's it! (It's making me wait 11minutes to accept but this will be accepted)
  • Krypes
    Krypes over 11 years
    More specifically ensure you are importing and/or aliasing the System.Collections.Generic namespace. Generic.List won't necessarily work unless he's imported System.Collections.
  • David Brunow
    David Brunow over 11 years
    Not sure of the situations, but I don't have to import System.Collections.Generic. Maybe because I am using ASP.NET?