ҡդӶ ʵŧ 纺촨շ٨絴͵ ᷹ФѺ

͵Դҷҧ Inbox Ѻ

˹ѡ
-
VB 6/VB.Net
ASP/ASP.Net
Ѻ¤
¹ҹ Flash Movie
ռͺش  
 RSS Feeds
 ǹŴ RSS Reader ...   Download  RSS Reader

Forum - www.g2gnet.com
Webmaster - www.g2gnet.com
Visitors - Session views
 5 6 1 6 1 4 9

7 ѹҤ ..2549
104 Users On-Line.
Visitors - Page views
 8 9 7 3 8 9 2
1 Ҿѹ ..2551

Google   
g2gnet.com
Ҵѡ:  

ҹẺ Text File MS FlexGrid MS Visual Basic 6.0

Category »  VB 6/VB.Net
: Webmaster 24/3/2551 13:13:00
(ҹ : 22854) 
Ҵͧͧ Text File ҨоٻẺͧèѴ红ŪԴ 繰ҹŢҴѡ 3 Ẻ ...
  • Ẻ¡пŴ ( ش) ͧ ͧҧ (Space chr(32)) , (Comma) ; (Semi-Colon) Tab
    1001,xxxxx,1111
    1002,xxxxxxxx,2222222
    1003,xx,33
    1 ¡ 1 Record ФѺ ѹԧѹж١¡͡ҡѹк÷Ѵ
    Carriage Return - CR Chr(13) 㹰ҹ 10 Chr(0D) 㹰ҹ 16
    Line Feed - LF Chr(10) 㹰ҹ 10 Chr(0A) 㹰ҹ 16
  • Ẻ˹Ǣͧŷ͹µ
    1001|xxxxxxxx|11
    1002|xxxxx___|22
    1003|xx______|33
    蹤 شáդ 4 ѡ ش 2 դ 8 ѡ ش 3 դ 2 ѡ
  • Ẻ 2 Ẻá
    1001 28-01-2008 07:15:00
    1001 28-01-2008 18:04:00
    1002 28-01-2008 07:58:00
    1002 28-01-2008 17:16:00
    ͵ҧйʹ㹺ͧѺͧ ... ѧࡵҢŪشá 1001, 1002 ѹʾѡҹ ( 4 ѡ) ҡѹ¡͡ªͧҧ (Space) ͪش 2 ѹ (10 ѡ) Ъش 3 (8 ѡ) ... 觷ءѡѹٻẺǷ͹µ ÷蹴ªͧҧͧҹѺӹǹǢͧЪش ( Record) ФѺ ... ͧ

    ҧ Text File Ѻҹ ͧҨҡͧ᡹¹ (Finger Scan) ˹ФѺ ... 㹧ҹ Time Attendance ... 觢Ũԧ ѹẺФѺ ѹ Error ºóẺ· 55555+
    Reference
    Project --> References ... --> Microsoft ActiveX Data Objects 2.8 Library

    Design Time
    ͡Ẻ - Design Time

    Run Time
    ӧҹ
    ǹŴ Source Code Ѻ MS Visual Basic 6.0 - Service Pack 6
     ǹŴ Visual Basic 6.0 SP5: Run-Time Redistribution Pack
     ǹŴ Microsoft Data Access Object (MDAC) Jet 4.0 Update
    
    Private Sub cmdReadText_Click()
    Dim CountRec As Long
    Dim StrData As String
    Dim iRow, i As Long
    Dim iArr As Variant
    Dim StrTemp As String
        
    Dim Conn As ADODB.Connection
    ' աǤѺҹ ... RS Promotion ... 
    Dim RS As ADODB.Recordset
    
    Set Conn = New ADODB.Connection
    Set RS = New ADODB.Recordset
        
        ' ٻẺ觢 (Data Source) ͧ Text File
        '
        Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
               "Data Source=" & App.Path & ";" & _
               "Extended Properties=""text;HDR=NO;FMT=Delimited;"";"
        
        ' ͧ͹ҹҧ (Table  Query) ¤Ѻ ... ͧ
        RS.Open "SELECT * FROM [Jan-2008#txt]", Conn, adOpenStatic, _
                            adLockReadOnly, adCmdText
        CountRec = RS.RecordCount
        ' ҹѹ繷º Դѹ
        Set RS = Nothing:    Set Conn = Nothing
        
        ' 駤Ѻ MS Flex Grid
        With fgData
            .Clear
            ' ӹǹ 4 ѡ
            .Cols = 4
            ' ˹ӹǹ (Rows) ӹǹ¡âŷ
            ' ӹǹǢա 1 ͧҡ Column Header ա 1 
            .Rows = CountRec + 1
            
            .ColWidth(0) = 1200
            
            ' ˹Ѻá  Column Header
            .TextMatrix(0, 0) = "ӴѺ"
            .TextMatrix(0, 1) = "ʾѡҹ"
            .TextMatrix(0, 2) = "ѹ/͡"
            .TextMatrix(0, 3) = "/͡"
        End With
        
        ' Դ Text File
        Open App.Path & "\Jan-2008.txt" For Input As #1
        
        iRow = 1    ' ʴŢŨҡǷ 1 (áФ  0 ФѺ ... ͧ)
        Do While iRow <= CountRec
            ' ҹҷк÷Ѵ
            Line Input #1, StrData
    
            '  Trim ͵Ѵͧҧ (Space) 駴ҹ˹  ѧͧشѡ͡
            StrTemp = Trim(StrData)
            ' ¡شѡ͡ҡѹ¤ Split
            ' ͧªͧҧ (Space) 㹡èѺ¡شѡ
            iArr = Split(StrTemp, " ")
            
            fgData.TextMatrix(iRow, 0) = iRow
            fgData.TextMatrix(iRow, 1) = iArr(0)
            fgData.TextMatrix(iRow, 2) = iArr(1)
            fgData.TextMatrix(iRow, 3) = iArr(2)
            iRow = iRow + 1
        Loop
        
        ' Դ Text File
        Close #1
    End Sub
    

  • ͵ - g2gNet Dot Com
    Ţ¹ҳԪ硷͹ԡ 0407314800231
    CopyLeft © 2004 - 2099 g2gNet.Com All rights reserved.
    Email: [email protected] . 08-6862-6560