........................
.......................
0.231 -1.29 -2.848 -3.263 -4.159 -3.224 -1.95
0.044 1.292 2.438 2.018 0.502 -0.868 2.065
3.093 0.168 -1.055 -0.414 -2.132 -4.681 -2.4
1.445 -0.551 1.208 1.754 1.408 0.127 0.366
1.461 1.725 0.937 0.615 -0.281 -1.986 -3.428
0.015 -0.026 -1.451 -0.428 1.596 1.546 0.394
3.36 4.767 4.56 2.988 0.211 -2.509 -2.908
-1.29 -0.953 -1.249 -1.998 -3.908 -3.131 0.142
4.671 4.834 4.727 4.699 2.93 0.644 -0.776
-2.223 -0.097 0.912 -1.308 -4.855 -3.859 -0.508
0.013 2.698 3.491 3.312 1.566 0.575 1.137
0.299 -2.998 -5.818
我用split和UBound只得出了列和行的个数,而我的这些数据最后一行的个数是变换的,比如我上面列出的例子,怎样才能读出总的个数,数据中间是空格,这些数据会有几千个。
.......................
0.231 -1.29 -2.848 -3.263 -4.159 -3.224 -1.95
0.044 1.292 2.438 2.018 0.502 -0.868 2.065
3.093 0.168 -1.055 -0.414 -2.132 -4.681 -2.4
1.445 -0.551 1.208 1.754 1.408 0.127 0.366
1.461 1.725 0.937 0.615 -0.281 -1.986 -3.428
0.015 -0.026 -1.451 -0.428 1.596 1.546 0.394
3.36 4.767 4.56 2.988 0.211 -2.509 -2.908
-1.29 -0.953 -1.249 -1.998 -3.908 -3.131 0.142
4.671 4.834 4.727 4.699 2.93 0.644 -0.776
-2.223 -0.097 0.912 -1.308 -4.855 -3.859 -0.508
0.013 2.698 3.491 3.312 1.566 0.575 1.137
0.299 -2.998 -5.818
我用split和UBound只得出了列和行的个数,而我的这些数据最后一行的个数是变换的,比如我上面列出的例子,怎样才能读出总的个数,数据中间是空格,这些数据会有几千个。
解决方案 »
- WebBrowser控件问题,请求帮助
- 关于imaglist的问题
- 为什么
- 怎么实现点击按扭,激活已经打开的文档啊??再线等!
- 各位大哥,请问怎样得到像Afx:400000:b:10011:6:0这样的窗口类的句柄?
- 在VB中连接本地mysql数据库?
- 400分求vb的约瑟夫环的写法,在线等!!~~~~~~~~~~~~~~~~~
- MSFlexGrid问题。
- 关于条形码的部题.
- vb问题请教:如何判断一个文件是否正在被某个进程占用?
- 用VB+SQL SERVER编程,当“rs!会员号”的值是NULL时,执行str1=Str(rs!会员号)时,出现“无效使用NULL错误”,谁有简单办法解决
- 关于几个鼠标事件?
split的时候以小数点为分隔符
dim count as long
dim ch as string
dim isNum as boolean
dim i as long
for i=1 to len(s)
ch = mid$(s,i,1)
if instr(1, "0123456789.+-", ch) <> 0 then
if not isNum then count = count+1
isNum = true
else
isNum = false
end if
next
numcount = count
end function
我将上面的代码改成了如下代码,不知道有什么错误:
Function numcount(ByVal s As String) As Long
Dim count As Long
Dim ch As String
Dim isNum As Boolean
Dim i As Long
Dim hFile As Integer hFile = FreeFile
Open App.Path & "\1.txt" For Input As #hFile
Do Until EOF(hFile)
Line Input #hFile, s
For i = 1 To Len(s)
ch = Mid$(s, i, 1)
If InStr(1, "0123456789.+-", ch) <> 0 Then
If Not isNum Then count = count + 1
isNum = True
Else
isNum = False
End If
Next
numcount = count
Loop
Close #hFile
End Function
Dim MaxValue As Single
Dim a As Integer
a = 0
hFile = FreeFile
Open App.Path & "\Wavex.dat" For Input As #hFile
Do Until EOF(hFile)
Line Input #hFile, tmp
If Trim(tmp) <> "" Then
tmp = Replace(tmp, vbTab, Space(1))
Do While InStr(tmp, Space(2))
tmp = Replace(tmp, Space(2), Space(1))
Loop
txtData = Split(tmp, Space(1))
For i = 0 To UBound(txtData)
If Abs(Val(txtData(i))) >= Abs(MaxValue) Then MaxValue = Val(txtData(i))
a = a + 1
Next i
End If
Loop
Close #hFilemsgbox a '得到点数
我用这段代码执行,对于只有一列的数据是满足的,可对于多列却总是大于实际的点数,不知道是什么问题怎么修改?
Dim hFile As Integer
Dim sFile As String
Dim arr() As String
Dim i As Integer hFile = FreeFile()
Open pFile For Binary As hFile
sFile = Space(LOF(hFile))
Get hFile, , sFile
Close hFile
sFile = Replace(sFile, vbCrLf, Chr(32))
sFile = Replace(sFile, Chr(9), Chr(32))
arr = Split(sFile, Chr(32))
For i = 0 To UBound(arr)
If Trim(arr(i)) <> "" Then GetCount = GetCount + 1
Next
End Function