'清理数组中重复的数据
Public Function ClearArray(A() As String, ByRef B() As String)
Dim i As Long
Dim j As Long
Dim N As Long
Dim L As Long
Dim Temp As Boolean
Dim Temp1 As String
N = UBound(A)
B(0) = A(0)
For i = 1 To N
Temp = False
Temp1 = A(i)
For j = 0 To UBound(B)
If Temp1 = B(j) Then Temp = True: Exit For
Next
If Temp = False Then
L = UBound(B)
ReDim Preserve B(L + 1)
B(L + 1) = Temp1
End If
Next
End Function
Public Function ClearArray(A() As String, ByRef B() As String)
Dim i As Long
Dim j As Long
Dim N As Long
Dim L As Long
Dim Temp As Boolean
Dim Temp1 As String
N = UBound(A)
B(0) = A(0)
For i = 1 To N
Temp = False
Temp1 = A(i)
For j = 0 To UBound(B)
If Temp1 = B(j) Then Temp = True: Exit For
Next
If Temp = False Then
L = UBound(B)
ReDim Preserve B(L + 1)
B(L + 1) = Temp1
End If
Next
End Function
'读取顺序文件到数组
Public Function ReadFileAsIndex(File_Name As String, ByRef Datas() As String) As Integer
On Error GoTo E:
Dim i As Long
i = 0
Dim FSO As FileSystemObject
Dim FSO_File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO_File = FSO.OpenTextFile(File_Name, ForReading, False) '读取文件而不创建
Do While Not FSO_File.AtEndOfStream
ReDim Preserve Datas(i)
Datas(i) = FSO_File.ReadLine
i = i + 1
Loop
FSO_File.Close
ReadFileAsIndex = 1
Exit Function
E:
ReadFileAsIndex = 0
'MsgBox Err.Description
End Function
Public Function ReadFileAsIndex(File_Name As String, ByRef Datas() As String) As Integer
On Error GoTo E:
Dim i As Long
i = 0
Dim FSO As FileSystemObject
Dim FSO_File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO_File = FSO.OpenTextFile(File_Name, ForReading, False) '读取文件而不创建
Do While Not FSO_File.AtEndOfStream
ReDim Preserve Datas(i)
Datas(i) = FSO_File.ReadLine
i = i + 1
Loop
FSO_File.Close
ReadFileAsIndex = 1
Exit Function
E:
ReadFileAsIndex = 0
'MsgBox Err.Description
End Function
[本日志由 田草 于 2008-01-25 04:01 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |