VB6.0-循序檔的讀取與listview的呈現<20點>

有一循序檔內容如下...

*

------------

"姓名","座號","性別","電話"

"王小明","441","男","2314525"

"考試次數","國文","英文","數學","自然","社會","備註"

"1","88","85","70","72","82","數理偏差"

"2","85","81","83","80","69","數理有進步.社會退步"

-------------

*

我會把它讀出來...

但是丟不進去"listview"裡面...

*

↓是循序檔與我想要的輸出格式<"listview">

http://tonyhsu1028.myweb.hinet.net/QA.rar

*

麻煩各位前輩幫個忙吧...

可以的話 麻煩也請交我"listview"的基本用法...

*

謝謝各位...

Update:

goodspeedliou ( 研究生 4 級 ) 您好:

你給我的程式碼...我看的懂...

但是...

今天的問題是...

*

考試次數 不是絕對的...

有些人可能只考一次...

有些人可能考五次...

這樣的語法該怎麼下呢??

*

我在想...是不是跟回圈的語法有關西

Update 2:

goodspeedliou ( 研究生 4 級 ) 您好:...

嘗試過您補充的語法...

呈現的結果卻是

...

"

"

,

"

"

*

發現兩個問題

1.跟預期輸出結果不符合

2.<">與<,>的符號仍然存在..有辦法可以讓他不顯示在格子裡面嗎??

3.ListView1.ListItems.Add 1, , "Hello" 這段語法在說什麼?

4.ListView1.ListItems.Item(1).SubItems(1) = "Hello 2" 這段語法在說什麼?

沒有3可以跑4媽??

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    Private Sub Command1_Click()

     

    ListView1.View = lvwReport: ListView1.GridLines = True: ListView1.ListItems.Clear

     

    If ListView1.ColumnHeaders.Count = 0 Then

     

    For i = 1 To 7: ListView1.ColumnHeaders.Add , , "": Next i

     

    End If

     

    Open "C:\id.txt" For Input As #1

     

    iCount = 1

     

    Do While Not EOF(1) 

     

    Line Input #1, z

     

    c = Split(Replace(z, """", ""), ",")

     

    ListView1.ListItems.Add iCount, , c(0)

     

    For i = 1 To UBound(c):ListView1.ListItems.Item(iCount).SubItems(i) = c(i):Next i

     

    iCount = iCount + 1

     

    Loop

     

    Close #1

     

    End Sub

    Source(s): 藍色小舖>>”阿戊”前輩
  • 1 decade ago

    這段程式給你參考, 你只要在Form裡面加入一個ListView和一個Button. 很簡單喔! 看完這段程式你應該就會寫了.

    Private Sub Form_Load()

    ListView1.View = lvwReport

    ListView1.ColumnHeaders.Add 1, , "COL1", 1000

    ListView1.ColumnHeaders.Add 2, , "COL2", 1000

    ListView1.ColumnHeaders.Add 3, , "COL3", 1000

    ListView1.ColumnHeaders.Add 4, , "COL4", 1000

    End Sub

    Private Sub Command1_Click()

    ListView1.ListItems.Add 1, , "Hello"

    ListView1.ListItems.Add 2, , "I"

    ListView1.ListItems.Add 3, , "am"

    ListView1.ListItems.Add 4, , "here"

    ListView1.ListItems.Item(1).SubItems(1) = "Hello 2"

    ListView1.ListItems.Item(2).SubItems(1) = "I 2"

    ListView1.ListItems.Item(3).SubItems(1) = "am 2"

    ListView1.ListItems.Item(4).SubItems(1) = "here 2"

    ListView1.ListItems.Item(1).SubItems(2) = "Hello 3"

    ListView1.ListItems.Item(2).SubItems(2) = "I 3"

    ListView1.ListItems.Item(3).SubItems(2) = "am 3"

    ListView1.ListItems.Item(4).SubItems(2) = "here 3"

    End Sub

    2009-01-30 16:01:47 補充:

    是的. 你可以用

    iCount = 1

    while not eof()

    Line Input #1, .....

    .....

    ListView1.Listitems.Add iCount,, ...

    ListView1.ListItems.Item(iCount).SubItems(1) = ....

    ListView1.ListItems.Item(iCount).SubItems(2) = ....

    iCount = iCount + 1

    wend

Still have questions? Get your answers by asking now.