Dim myPath as String() 和 Dim myPath() as String 什么区别?
vb.net吧
全部回复
仅看楼主
level 1
下面是我编的一个小程序,现在已经可以正常运行,但不是最终我想要的样子。
小小的疑问。
Public Class Form1
Private Sub ListView1_DragDrop(sender As Object, e As DragEventArgs) Handles ListView1.DragDrop
ListView1.FullRowSelect = True
ListView1.Items.Clear()
Dim droppedItems As String() = e.Data.GetData(DataFormats.FileDrop)
Dim selectedItem As String = droppedItems(0) '路径
Label1.Text = selectedItem
Dim j As Integer = My.Computer.FileSystem.GetFiles(selectedItem).Count
Dim newFilelist As String() = GetImageList(selectedItem, j)    '这一句
For Each myImage In newFilelist
MsgBox(myImage)
Next
End Sub
Private Sub ListView1_DragEnter(sender As Object, e As DragEventArgs) Handles ListView1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) = True Then
e.Effect = DragDropEffects.All
End If
End Sub
'以数组形式返回文件夹下面的文件名称
Function GetImageList(ByVal imagePath As String, ByVal j As Integer) As String()
Dim i As Integer = 1
Dim newFolder() As String            '和这一句
ReDim newFolder(j - 1)
For Each foundFile As String In My.Computer.FileSystem.GetFiles(imagePath)
Dim attributes As IO.FileAttributes
attributes = IO.File.GetAttributes(foundFile)
If (attributes And IO.FileAttributes.Hidden) <> IO.FileAttributes.Hidden Then
Dim fileName As String = IO.Path.GetFileName(foundFile)
newFolder(i - 1) = fileName
i += 1
End If
Next
Return newFolder
End Function
End Class
2017年09月08日 10点09分 1
level 7
没区别
2017年09月08日 12点09分 2
感谢!
2017年09月10日 14点09分
level 11
没区别,但是msdn联系用后面那种,不过很神奇的是当你需要声明固定大小的数组时,后面那种没法用,只能用前面那种,很尴尬[黑线]
2017年09月08日 18点09分 3
联系改成建议
2017年09月08日 18点09分
@闪星2 那MSDN还建议。。。
2017年09月10日 14点09分
dim str as string()=new string(5){是否可以?}
2017年09月12日 14点09分
1