如题,txt文件的数据是一个周期的sin函数,数据格式如下:
0            0 
.01          9.999833E-03 
.02          1.999867E-02 
.03          .0299955 
.04          3.998933E-02 
.05          4.997917E-02 
5.999999E-02                .059964 
6.999999E-02                6.994284E-02 
7.999999E-02                7.991468E-02 
8.999999E-02                8.987854E-02 
9.999999E-02                9.983341E-02 
.11          .1097783 
.12          .1197122 
.13          .1296341 
......
谢谢各位高手相助

解决方案 »

  1.   

    Option Explicit
    Const Ratio = 1
    Const Offset = 1Private Type TPoint
        x As Double
        y As Double
    End TypePrivate Sub Command1_Click()
    Picture1.ScaleMode = 7
    Dim s As String, p() As TPoint, N As Integer
    Dim arrS() As String
    Open "d:\tddownload\data.txt" For Input As #1
        Do While Not EOF(1)
            Line Input #1, s
            ReDim Preserve p(N)
            arrS = Split(Trim(s), " ")
            With p(N)
                .x = Val(arrS(0))
                .y = Val(arrS(UBound(arrS)))
            End With
            N = N + 1
        Loop
    Close #1
    DrawCurve Picture1, p
    End SubPrivate Sub DrawCurve(pic As PictureBox, p() As TPoint)
    If UBound(p) < 1 Then MsgBox "数据不足": Exit Sub
    pic.Line (Ratio * p(0).x, Ratio * p(0).y + Offset)-(Ratio * p(1).x, Ratio * p(1).y + Offset), vbCyan
    Dim i As Integer
    For i = 2 To UBound(p)
        pic.Line -(Ratio * p(i).x, Ratio * p(i).y + Offset), vbCyan
    Next i
    End Sub