ٶǸѵĻش
2012/4/4 1:47:14  ٶ֪   58040 1303

 ǸٶǸѵĻش

Ϊڰٶ޷룬شˣԴ

 

********ģ鼶**********************************************

'ģ鼶ڶȡtxtļе겢һ

Public Function GetPoints(ByVal AppPath As String, ByRef P() As Single)
  '˵AppPathݵ·硰D:/zuobiao.txt App.Path & "/zuobiao.txt"
  '          P()һյڷش洢ڵͣ2Ϊֱߡ3ΪԲֵ
  '          P()жά P(xy)xΪ(1ʼ)y=0123(0͡1=X2=Y3=Z)
  Dim Strline As String, Line_Type As Integer, a() As String
  Dim Points As Long
  Strline = ""
  Points = 0
  Open AppPath For Input As #1
    Do Until EOF(1)
      Line Input #1, Strline
      Strline = Trim(Strline)
      If Strline <> "" Then
        Select Case Strline
        Case "2"
          Points = Points + 2
        Case "3"
          Points = Points + 3
        End Select
      End If
    Loop
  Close #1
  ReDim P(Points, 3)
  
  Strline = "": Line_Type = 0: i = 0
  Open AppPath For Input As #2
    Do Until EOF(2)
      Line Input #2, Strline
      Strline = Trim(Strline)
      If Strline <> "" Then
        If Strline <> "2" And Strline <> "3" And Strline <> "4" Then i = i + 1
        Select Case Strline
        Case "2"
          Line_Type = 2
        Case "3"
          Line_Type = 3
        Case "4"
          Line_Type = 0
        Case Else
          a() = Split(Strline, ",")
          P(i, 0) = Line_Type: P(i, 1) = a(0): P(i, 2) = a(1): P(i, 3) = a(2)
        End Select
      End If
    Loop
  Close #2
End Function


*************Ǵڼʾ**************************

'Ǹĵʾform1еcommand1ڵúӡ洢Ľ
Private Sub Command1_Click()
  Dim X() As Single   'һ洢Ŀ
  Call GetPoints(App.Path & "\zuobiao.txt", X()) 'ú
  For i = 1 To UBound(X)  '洢ĵ1άά֮
    'ڴϴӡ֤
    Print X(i, 0) & "  (" & X(i, 1) & "" & X(i, 2) & "" & X(i, 3) & ")"
    '棺              X            Y             Z
  Next
End Sub

 




ļ(1)


ʹáѸסأĵûаװѸ׿޷
Լ·뽫زķiz88@sina.cnϸ˵