台灣最大程式設計社群網站
線上人數
1674
 
會員總數:243299
討論主題:188081
歡迎您免費加入會員
討論區列表 >> VB6 >> Vb6 list 存檔問題
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
Vb6 list 存檔問題
價值 : 30 QP  點閱數:294 回應數:1

樓主

JJ
門外漢
0 9
136 12
發送站內信

各位大大好:
我利用下面的程式碼把txt的檔案讀檔到list1.list,請問如何又把list1.list另存到另一個 .txt檔呢?(p.s.檔案數超過32767)

Private Sub Command1_Click()
Dim f As Long, s() As String, i As Single, j As Single
List1.Clear
strMsg = ""

Close #f
f = FreeFile

List1.Visible = False: DoEvents


On Error GoTo ErrHandler


f = FreeFile

With CmDialog1
.CancelError = True
.DialogTitle = "開啟檔案"
.Filter = "txt File (*.*)|*.txt;|txt files(*.txt)|*.txt"
.ShowOpen
f = FreeFile
Open .FileName For Binary As #f
End With
ReDim a(LOF(f) - 1) As Byte
Get #f, , a
Close #f
s = Split(StrConv(a, vbUnicode), vbCrLf)
i = UBound(s)
If i > 32767 Then
ProgressBar1.Max = 32767: i = 32767 / i
Else
ProgressBar1.Max = i: i = 1
End If
ProgressBar1 = 0
List1.Visible = False
DoEvents
On Error Resume Next
For f = 0 To UBound(s)
List1.AddItem s(f)
j = j + 1 * i
ProgressBar1 = j
Next
List1.Visible = True



Close #f
List1.Visible = True
List2(lstCnt).Visible = True
ErrHandler:
If Err <> CancelError Then MsgBox Error
Exit Sub

搜尋相關Tags的文章: [ vb6 list.list ] ,
本篇文章發表於2018-02-21 15:00
別忘捐VP感謝幫助你的人 新手會員瞧一瞧
1樓
作者回應

JJ
檢舉此回應
目前用這方法可以存超過32767,但還差了一些資料沒存完整,請問怎麼修程式碼呢?

Private Sub Command2_Click()
Dim i As Long

Close #f
nCount = SendMessage(List1.hwnd, LB_GETCOUNT, 0, 0)

With CmDialog1
.CancelError = True
.DialogTitle = "開啟檔案"
.Filter = "txt File (*.*)|*.txt;|txt files(*.txt)|*.txt"
.ShowOpen
Text1.Text = .FileTitle
f = FreeFile
Open .FileName For Output As #f
End With

Dim s As String
Dim strItem As String * 256
nCount = SendMessage(List1.hwnd, LB_GETCOUNT, 0, 0)

For i = 0 To nCount - 1


'List2(lstCnt).AddItem Trim(i)


Call SendMessageByString(List1.hwnd, LB_GETTEXT, i, strItem)
s = Trim0(strItem)


Print #f, s



Next

End Sub
本篇文章回覆於2018-02-23 23:17
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.