文档格式如下:
11:41:15 0 32 32 32 31 31 31 64 50 26 26 26
11:41:16 1 32 32 32 25 31 31 65 50 26 26 26 每个值都要读入不同的变量,请问如何用程序实现?
11:41:15 0 32 32 32 31 31 31 64 50 26 26 26
11:41:16 1 32 32 32 25 31 31 65 50 26 26 26 每个值都要读入不同的变量,请问如何用程序实现?
解决方案 »
- 求一延时小程序
- adodb.stream.writetext时显示“在此环境中不允许操作”,求问如何解决,谢谢!
- 考虑半天还是提问。关于读取汉字点阵。
- 数据环境是怎么回事???在线等!!!
- 请教:如何控制用webbrowser中的网页的字体的大小?
- 我是个VB初学者,我最近在试着编一个计算器,有些问题不明白,请高手赐教
- 一个简单的问题,Dim dt1 As Data,dt1 = selecttime.dtpStart.Value为什么是错误的呢?
- 如何删除一个文件的内容?
- 高手请进,四舍五入问题
- 我用VB写了个软件,请高手指点指点!
- 写入注册表失败:字符串自动截断了。哪位大虾帮忙解决
- 整个程序都遇到同一个问题———好郁闷!
'GetAllElement用于取得各列的值。
public type Mydata
Element1 as string
...............
Element13 as string
end typepublic function GetAllElement(byval strLine as string,optional SplitChar=space(1)) as mydatadim AllElementAllElement=split(strline,splitchar)
with GetAllElement
.Element1=AllElement(0)
........
end with
end functionpublic function ReadFileLine(ByVal strFile As String,byval lngLineNo as long) as string
dim strContent as string
dim ALLLine
strcontent=ReadFileAsString(strfile)
allline=split(strcontent,vbcrlf)
ReadFileLine=allline(lnglineno-1)
end function
Public Function ReadFileAsByte(ByVal strFile As String, ByRef FileByte() As Byte) As Long
Dim hFile As Long
Dim lngFileSize As Long
Dim bRead As Long
Dim TmpPos As Long
Dim Sum As Long
Dim dwBytesRead As Long
Dim pBuffer(64511) As Byte
'If FileExist(strFile) = False Then Exit Function
hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ, 0&, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0&)
If hFile = INVALID_HANDLE_VALUE Then Exit Function
lngFileSize = GetFileSize(hFile, 0&)
If lngFileSize <= 0 Then Exit Function
ReDim FileByte(lngFileSize) As Byte
Sum = 0
Do
DoEvents: DoEvents: DoEvents
bRead = ReadFile(hFile, pBuffer(0), 64511, dwBytesRead, 0&)
TmpPos = VarPtr(FileByte(0)) + Sum
CopyMemory ByVal TmpPos, ByVal VarPtr(pBuffer(0)), ByVal dwBytesRead
Sum = Sum + dwBytesRead
DoEvents: DoEvents: DoEvents
Loop Until Sum >= lngFileSize
ReadFileAsByte = lngFileSize
CloseHandle hFile
End Function
Public Function ReadFileAsString(ByVal strFile As String) As String
Dim FileByte() As Byte
ReadFileAsByte strFile, FileByte()
ReadFileAsString = StrConv(FileByte(), vbUnicode) 'Byte2StringEnd Function
Dim x() As String, y() As String, b() As Byte, temp() As String, i As Integer, j As Integer
Open "c:\xx.txt" For Binary As #1
ReDim b(LOF(1))
Get #1, , b
Close #1
x = Split(StrConv(b, vbUnicode), vbCrLf)
Erase b
ReDim y(UBound(x), 13)
For i = 0 To UBound(x)
temp = Split(x(i), " ")
If UBound(temp) = 1 Then
Exit For
Else
For j = 0 To UBound(temp)
y(i, j) = temp(j)
Next
MsgBox Join(temp, vbCrLf), 0, y(i, 0)
End If
Next
End Sub