Array initialisation values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Dann

    #1

    Array initialisation values

    I want to populate a list box with the names of a set of files in a
    particular folder with the same file type, so:

    Dim MyArray as string = Directory.Getfi les(Path, ".etc")

    But if the number of file names returned is zero, what state is the
    array in and how can I test for this condition and distinguish it from
    when just one file name is returned? (MyArray Is Nothing seems to be
    False always)

    Thanks
    JGD
  • CT

    #2
    Re: Array initialisation values

    You can check the Length property on the array. If it's 0...

    --
    Carsten Thomsen
    Enterprise Development with VS .NET, UML, AND MSF


    "John Dann" <news@prodata.c o.uk> wrote in message
    news:sn35b1ld57 pmcuk60i9dj3f8b 92piju4db@4ax.c om...[color=blue]
    >I want to populate a list box with the names of a set of files in a
    > particular folder with the same file type, so:
    >
    > Dim MyArray as string = Directory.Getfi les(Path, ".etc")
    >
    > But if the number of file names returned is zero, what state is the
    > array in and how can I test for this condition and distinguish it from
    > when just one file name is returned? (MyArray Is Nothing seems to be
    > False always)
    >
    > Thanks
    > JGD[/color]


    Comment

    • Josip Habjan

      #3
      Re: Array initialisation values

      John,
      try:
      Dim MyArray() As String = Directory.GetFi les("", ".etc")
      ...and then
      If MyArray.Length > 0 Then
      ... do something
      End If

      Regards,
      Josip Habjan
      URL: http://www.habjansoftware.com



      "John Dann" <news@prodata.c o.uk> wrote in message
      news:sn35b1ld57 pmcuk60i9dj3f8b 92piju4db@4ax.c om...[color=blue]
      >I want to populate a list box with the names of a set of files in a
      > particular folder with the same file type, so:
      >
      > Dim MyArray as string = Directory.Getfi les(Path, ".etc")
      >
      > But if the number of file names returned is zero, what state is the
      > array in and how can I test for this condition and distinguish it from
      > when just one file name is returned? (MyArray Is Nothing seems to be
      > False always)
      >
      > Thanks
      > JGD[/color]


      Comment

      Working...