Построение графиков

Тема в разделе "Visual Basic", создана пользователем -, 7 май 2011.

  1. Гость

    Имеется программа! Подскажите что в ней и как надо изменить, чтобы график строился

    Dim k() As Single, t() As Single, tk() As Single, kr() As Single, n As Integer
    Private Sub mnuExit_Click()
    End
    End Sub

    Private Sub mnuOpen_Click()
    Dim filname As String, i As Integer
    CommonDialog1.Action = 1
    filname = CommonDialog1.FileName
    Open filname For Input As #1
    Input #1, n
    ReDim k(1 To n) As Single, t(1 To n) As Single, tk(1 To n) As Single, kr(1 To n) As Single
    With MSFlexGrid1
    .Cols = 6: .Rows = n + 1: .FixedCols = 1: .FixedRows = 1
    .Col = 0: .Row = 0: .Text = "#": .Col = 1: .Text = "t,'C"
    .Col = 2: .Text = "T,K": .Col = 3: .Text = "K": .Col = 4: .Text = "Kr": .Col = 5: .Text = "Eps,%"
    For i = 1 To n
    .Row = i: .Col = 0: .Text = CStr(i)
    Input #1, t(i), k(i)
    .Col = 1: .Text = CStr(t(i))
    tk(i) = t(i) + 273
    .Col = 2: .Text = CStr(tk(i))
    .Col = 3: .Text = CStr(k(i))
    Next i
    End With
    Close #1
    End Sub

    Private Sub mnuResh_Click()
    Dim i As Integer, k0 As Single, E As Single, a As Single, b As Single
    Dim x1() As Single, y1() As Single, eps() As Single
    Dim gr() As Single
    ReDim x1(1 To n) As Single, y1(1 To n) As Single, eps(1 To n) As Single
    ReDim gr(1 To n, 1 To 4) As Single
    For i = 1 To n
    x1(i) = 1 / (tk(i))
    y1(i) = Log(k(i))
    Next i
    Call koefAB(n, x1(), y1(), a, :)
    k0 = Exp:))
    E = -a * 8.315
    With MSFlexGrid1
    For i = 1 To n
    kr(i) = k0 * Exp(-E / (8.315 * tk(i)))
    eps(i) = Abs(k(i) - kr(i)) / Abs(k(i)) * 100
    .Row = i: .Col = 4: .Text = CStr(kr(i))
    .Col = 5: .Text = CStr(eps(i))
    Next i
    End With
    Text1.Text = CStr(k0)
    Text2.Text = CStr(E)
    MSChart1.chartType = 16
    For i = 1 To n
    gr(i, 1) = t(i): gr(i, 3) = t(i)
    gr(i, 2) = k(i): gr(i, 4) = kr(i)
    Next i
    MSChart1.ChartData = gr
    End Sub
    Sub koefAB(n As Integer, x() As Single, y() As Single, a As Single, b As Single)
    Dim i As Integer, s1 As Single, s2 As Single, s3 As Single, s4 As Single
    s1 = 0: s2 = 0: s3 = 0: s4 = 0
    For i = 1 To n
    s1 = s1 + x(i)
    s2 = s2 + x(i) * x(i)
    s3 = s3 + x(i) * y(i)
    s4 = s4 + y(i)
    Next i
    a = (n * s3 - s1 * s4) / (n * s2 - s1 * s1)
    b = (s2 * s4 - s1 * s3) / (n * s2 - s1 * s1)
    End Sub

    Private Sub mnuSaveAs_Click()
    Dim filname As String, i As Integer
    CommonDialog1.Action = 2
    filname = CommonDialog1.FileName
    If Right(filname, 4) <> ".txt" Then filname = filname + ".txt"
    Open filname For Output As #1
    Print #1, "t C", "t K", "K", "Kr"
    For i = 1 To n
    Print #1, t(i), tk(i), k(i), kr(i)
    Next i
    Close #1
    End Sub



    обращение к файлу - создать файл в блокноте с содержанием:
    7
    320 0.216
    345 0.384
    370 0.468
    395 0.652
    420 0.913
    445 1.251
    470 1.586
     
Загрузка...
Похожие Темы - Построение графиков
  1. Gargon
    Ответов:
    5
    Просмотров:
    859
  2. OksanaS
    Ответов:
    47
    Просмотров:
    8.183
  3. yyyuuu
    Ответов:
    2
    Просмотров:
    1.063
  4. Dragon108
    Ответов:
    2
    Просмотров:
    937
  5. klyblg
    Ответов:
    0
    Просмотров:
    1.524

Поделиться этой страницей