質問

I am using a function to select a few files:

Module OpenFileMod
Public Function OpenFile() As String()
    'declare a string, this is will contain the filename that we return
    Dim strFileNames As String()
    'declare a new open file dialog
    Dim fileDialogBox As New OpenFileDialog()

    fileDialogBox.Filter = "Excel Files (*.xls)|*.xls"
    fileDialogBox.Multiselect = True

    'this line tells the file dialog box what folder it should start off in first
    'I selected the users my document folder
    fileDialogBox.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal)

    'Check to see if the user clicked the open button
    If (fileDialogBox.ShowDialog() = DialogResult.OK) Then
        strFileNames = fileDialogBox.FileNames
    Else
        MsgBox("You did not select a file!")
    End If

    'return the name of the file
    Return strFileNames
End Function
End Module

I would like to know how many files the user has chosen.

How can I do that?

役に立ちましたか?

解決

fileDialogBox.FileNames is an array, so you can simply check its Length property

or

strFileNames.Length
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top