Private Sub Command1_Click()
Dim filename As String
Dim l As Long
filename = "d:\mc\tt.txt"
l = FileLen(filename)
Dim buff() As Byte
ReDim buff(l - 1)
Open filename For Binary As #1
Get #1, , buff
Close #1
Dim s As String
s = StrConv(buff, vbUnicode)
s = Replace(s, "[", "")
s = Replace(s, "]", "")
Dim arr, arrtemp
arr = Split(s, vbCrLf)
Dim i As Long, k As Long
Dim VarLower() As Long
Dim VarUpper() As Long
k = 0
For i = 0 To UBound(arr)
If Len(arr(i)) <> 0 Then
arrtemp = Split(arr(i), ",")
If UBound(arrtemp) = 2 Then
ReDim Preserve VarUpper(k)
VarUpper(k) = CLng(Trim(arrtemp(2)))
ReDim Preserve VarLower(k)
VarLower(k) = CLng(Trim(arrtemp(1)))
k = k + 1
End If
End If
Next
List1.Clear
List2.Clear
For i = 0 To UBound(VarLower)
List1.AddItem CStr(VarLower(i))
List2.AddItem CStr(VarUpper(i))
Next
End Sub
用法:传回数组 = Split(原始字串, 要找的字串, 拆成几个数组)
Private Sub Command1_Click()
Dim MyStr As String
MyStr = "1234567123456712345"
MyStrs = Split(MyStr, "67")
For Each Strs In MyStrs
Print Strs
Next
End Sub
●输出结果:"12345"、"12345"、"12345"
Private Sub Command1_Click()
Dim MyStr As String
MyStr = "1234567123456712345"
MyStrs = Split(MyStr, "67", 2)
For Each Strs In MyStrs
Print Strs
Next
End Sub
●输出结果:"12345"、"123456712345"
数组里面的是数值型吗?
dim Low as Integer
dim Big as integer
for i=0 to 10
for j=0 to 1000
if x1(i,j)<Low then Low=x1(i,j)
if x1(i,j)>Big then Big=x1(i,j)
next
next
范围为 x1>=Low x1<=Big