English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

1.如何將文字檔讀取於MSHFlexGrid及Spreadsheet中
2.附文字檔:
http://member.giga.net.tw/smart0129/123.txt
3.圖示如下:
http://member.giga.net.tw/smart0129/vb_excel.jpg

2007-01-15 11:36:16 · 1 個解答 · 發問者 小欽仔 1 in 電腦與網際網路 程式設計

1 個解答

參考如下MSFlexGrid存檔與讀檔....
存檔:
Open "C:\Documents and Settings\Administrator\桌面\1.save" For Output As #1

Print #1, MSFlexGrid1.FixedCols & "+" & MSFlexGrid1.FixedRows & "+" & MSFlexGrid1.Cols & "+" & MSFlexGrid1.Rows

For a = 0 To MSFlexGrid1.Rows - 1
MSFlexGrid1.Row = a
ColCombient = ""
For b = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Col = b
If MSFlexGrid1.Col = Val(MSFlexGrid1.Cols - 1) Then
ColCombient = ColCombient & MSFlexGrid1.Text
Else
ColCombient = ColCombient & MSFlexGrid1.Text & ","
End If
Next b

Print #1, ColCombient
Next a
Close #1

讀檔:

Open "C:\Documents and Settings\Administrator\桌面\1.save" For Input As #1
Line Input #1, mydat
Data1 = Split(mydat, "+")
MSFlexGrid1.Cols = Data1(2)
MSFlexGrid1.Rows = Data1(3)
'先讀出MSFlexGrid1的基本資料
'--------------------------------------------------------
'在讀出儲存隔的檔案!
For Idx = 0 To Data1(3) - 1
MSFlexGrid1.Row = Idx
Line Input #1, mydat
Data2 = Split(mydat, ",")
For Idy = 0 To UBound(Data2)
MSFlexGrid1.Col = Idy
MSFlexGrid1.Text = Data2(Idy)
Next
Next
Close #1
你可以手動key入然後看上面的方式讀檔和存檔這樣就可以從文字檔讀到MSFlexGrid
當然可能很麻煩!或許你有更好的方法或想法也可以順便教我ㄚ!
因為我也是MSFlexGrid的愛用者!
我是想用MSFlexGrid聯接資料庫然後轉存文字檔這樣以後我就可以用文字檔讀取或從資料庫去讀取!兩者選一!
參考看看!
我是有令一種寫法但是我想不知是否可行!
致於

2007-01-16 09:35:52 補充:
致於 Spreadsheet我還沒研究!sorry
我盡力了!

2007-01-16 09:54:28 補充:
你也可以參考如下
http://tw.knowledge.yahoo.com/question/question?qid=1106071602048

2007-01-16 04:33:55 · answer #1 · answered by 5 · 0 0

fedest.com, questions and answers