首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

有没有好的方法来读这些数据解决方案

2012-01-14 
有没有好的方法来读这些数据TEXT.TXT保存着下面一些数据123123,434231,irjdxa242434,534242,ki-kid132324,

有没有好的方法来读这些数据
TEXT.TXT保存着下面一些数据
123123,434231,irjdxa
242434,534242,ki-kid
132324,3213f1,9i9d_df
akcjdd,1121fr,ik9243d
  .                 .             .      
  .                 .             .
  .                 .             .
  .                 .             .


-------------------------------------------
有没有好的方法以逗号分割符来读里面的数据
在线等啊


[解决办法]
补充一下,先要把txt按行读出,然后用split,按行读的代码:
Public Function ReadTxtByLine(ByRef strReadLineArray() As String, ByVal strFilePath As String) As Boolean
Dim i As Integer
Dim fsoWriteTxt As New FileSystemObject
Dim tsFile As TextStream

i = 0
ReadTxtByLine = False
If fsoWriteTxt.FileExists(strFilePath) Then
Set tsFile = fsoWriteTxt.OpenTextFile(strFilePath, ForReading, False, TristateUseDefault)
Do While tsFile.AtEndOfStream <> True
ReDim Preserve strReadLineArray(i) As String
strReadLineArray(i) = tsFile.ReadLine
i = i + 1
Loop
tsFile.Close
ReadTxtByLine = True
Else
MsgBox (strFilePath & "不存在! "), vbOKOnly, "提示 "
End If
Set fsoWriteTxt = Nothing
Set tsFile = Nothing
End Function
[解决办法]
Private Sub Form_Click()

Dim s() As Byte, ss() As String, fileln As Long
Open "e:\1.txt " For Binary As #1
fileln = LOF(1)
ReDim s(fileln - 1)
Get #1, 1, s
ss = Split(Replace(StrConv(s, vbUnicode), vbCrLf, ", "), ", ")
For i = 0 To UBound(ss)
If ss(i) <> " " Then Debug.Print "序号 "; i + 1, ss(i)
Next
Close #1
End Sub

热点排行