Dim $avArray, $i = 0, $Chdir = "D:\DOWNLOAD\2011\"
$search = FileFindFirstFile($Chdir & "*.*")
If $search = -1 Then Exit (MsgBox(0, "Error", "No files/directories matched the search pattern"))
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$i += 1
ReDim $avArray[$i]
$avArray[$i - 1] = $file
WEnd
FileClose($search)
MsgBox(4096, "index:", _ArrayMin($avArray, 1)) 回复 15# 3mile
还是未能解决,奇怪了! 回复 16# afan
谢谢你了,我下次一定会用代码标签的,你帮我解决了困惑好久的问题。关键是ReDim $avArray[$i]这句简直太神奇了,没有看出来它这么大作用! 学习学习再学习,谢谢 本帖最后由 netegg 于 2011-4-13 14:55 编辑
你那堆文件的文件名是什么模样的
另外_arraysort()不行吗 本帖最后由 foboy 于 2011-4-13 19:51 编辑
献上俺写的一个函数:
;排序一个数组。
;参数:$_the_array:原数组;$_mode:0-从大到小/1-从小到大;$_mode_ex:0-返回的数组内容为排序后的数值 1-返回的数组为原数组排序后的序列(角标),例如原数组是,按由大到小排列是,在此模式下函数返回的是其顺序号:
Func _paixu($_the_array, $_mode = 0, $_mode_ex = 0)
$_date_num = UBound($_the_array)
Local $_xulies[$_date_num]
For $_j = 0 To $_date_num - 1
$_xulies[$_j] = $_j
Next
For $_i_index = 0 To $_date_num - 2
For $_i = 0 To $_date_num - $_i_index - 2
If $_mode == 0 Then
If $_the_array[$_i] <= $_the_array[$_i + 1] Then
$_num_linshi = $_xulies[$_i]
$_xulies[$_i] = $_xulies[$_i + 1]
$_xulies[$_i + 1] = $_num_linshi
$_num_linshi = $_the_array[$_i]
$_the_array[$_i] = $_the_array[$_i + 1]
$_the_array[$_i + 1] = $_num_linshi
EndIf
Else
If $_the_array[$_i] >= $_the_array[$_i + 1] Then
$_num_linshi = $_xulies[$_i]
$_xulies[$_i] = $_xulies[$_i + 1]
$_xulies[$_i + 1] = $_num_linshi
$_num_linshi = $_the_array[$_i]
$_the_array[$_i] = $_the_array[$_i + 1]
$_the_array[$_i + 1] = $_num_linshi
EndIf
EndIf
Next
Next
If $_mode_ex == 1 Then
Return $_xulies
Else
Return $_the_array
EndIf
EndFunc ;==>_paixu
页:
1
[2]