Несколько курсовых работ (Форма)

Посмотреть архив целиком

Public Class Form1


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ReDim A1(n, 2), B1(m, 2)

For i = 0 To n - 1

For j = 0 To 1

A1(i + 1, j + 1) = CSng(Me.DataGridView1.Item(j, i).Value)

Next

Next

For i = 0 To m - 1

For j = 0 To 1

B1(i + 1, j + 1) = CSng(Me.DataGridView2.Item(j, i).Value)

Next

Next

interpol()

End Sub


Private Sub ЗагрузитьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ЗагрузитьToolStripMenuItem.Click

Me.OpenFileDialog1.ShowDialog()

End Sub


Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

If fl = 0 Then

loadsystemfromfile(Me.OpenFileDialog1.FileName, Me.DataGridView1)

n = n1 + 1

Else

loadsystemfromfile(Me.OpenFileDialog1.FileName, Me.DataGridView2)

m = n1 + 1

End If

End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim it As Integer

Dim osth As Single

Dim otv As String

stp = CSng(Me.TextBox2.Text)

itmax = CInt(Me.TextBox4.Text)

eps = CSng(Me.TextBox3.Text)

otv = "Абсолютный коэффициент термоэдс Sa(T)" + Chr(13)

For i = 1 To n

otv = otv + CStr(Sa(i, 1)) + " " + CStr(Sa(i, 2)) + Chr(13)

Next

osth = 0

approks(stp)

Zeidel(itmax, it, stp)

For i = 1 To n

osth = osth + (Sa(i, 2) - fynk(Sa(i, 1), stp)) ^ 2

osth = osth ^ 0.5

Next

' otv = otv + "Mатрица Грамма" + Chr(13)

' For i = 0 To stp

'For j = 0 To stp

'otv = otv + CStr(B2(i, j)) + " "

' Next


' otv = otv + " = " + CStr(B(i)) + Chr(13)

' Next

otv = otv + "Коэфф Гаусс-Зейдель: " + Chr(13)

For i = 0 To stp

otv = otv + "C" + CStr(i) + "=" + CStr(C(i)) + Chr(13)

Next

otv = otv + Chr(13) + "Кол-во итераций it=" + CStr(it) + Chr(13) + Chr(13) + "Ошибка аппроксимации Q = " + CStr(osth) + Chr(13)

Me.RichTextBox1.Text = otv

End Sub


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim h, xx1, x, xx2, y1, y2, mh, mw, msx, msy, ms, TA, TB As Single

Dim otv As String

Dim graph As Graphics = Me.PictureBox2.CreateGraphics

Dim pn As Pen = New Pen(Color.Black, 2)

Dim pn1 As Pen = New Pen(Color.Brown, 2)

Me.PictureBox2.Refresh()

mh = CSng(Me.PictureBox2.Height) / 2

mw = CSng(Me.PictureBox2.Width) / 2

MS = CSng(Me.TextBox1.Text)

msx = mw / (Sa(n, 1) * ms)

msy = mh / (Sa(n, 1) * ms / 50)

graph.TranslateTransform(0, mh)

graph.DrawLine(pn, 0, -mh * 2, 0, mh * 2)

graph.DrawLine(pn, mw * 2, 0, -mw * 2, 0)

h = 0.05 : K1 = 0

TA = Sa(1, 1) : TB = Sa(1, 1)

For i = 1 To n

If Sa(i, 1) < TA Then

TA = Sa(i, 1)

Else

If Sa(i, 1) > TB Then

TB = Sa(i, 1)

End If

End If

Next

For x = TA To TB Step h

xx1 = x

xx2 = (xx1 + h)

y1 = -fynk(xx1, stp)

y2 = -fynk(xx2, stp)

If y1 * y2 < 0 Then K1 = K1 + 1

graph.DrawLine(pn, msx * xx1, y1 * msy, msx * xx2, y2 * msy)

Next

For i = 1 To n

graph.DrawRectangle(Pens.ForestGreen, msx * Sa(i, 1) - 1, -msy * Sa(i, 2) - 1, 2, 2)

Next

Me.RichTextBox1.Text = Me.RichTextBox1.Text + "Кол-во корней= " + CStr(K1) + Chr(13)

iter = 0

otv = Chr(13) + "Корень: " + CStr(hord(TA, TB)) + Chr(13)

otv = otv + "Число итераций=" + CStr(iter) + Chr(13)

Me.RichTextBox1.Text = Me.RichTextBox1.Text + otv

End Sub


Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim h, kof, vb, etk As Single

Dim otv As String

Dim i, j As Integer

ReDim E1(n, 2), E2(n, 2)

h = CSng(Me.TextBox6.Text)

kof = CInt(Me.TextBox7.Text)

i = 50 : j = 0

Do

If i < 1000 Then

i = i + 50 : j = j + 1

E1(j, 1) = i

E1(j, 2) = pr(Sa(1, 1), Sa(j, 1), h)

runge(Sa(1, 1), Sa(j, 1), h)

E1(j, 2) = E1(j, 2) + Rung

Else

i = i + 20 : j = j + 1

E1(j, 1) = i

E1(j, 2) = pr(Sa(1, 1), Sa(j, 1), h)

runge(Sa(1, 1), Sa(j, 1), h)

E1(j, 2) = E1(j, 2) + Rung

End If

Loop Until i = Sa(n, 1)

otv = "Зависимость E(T), интегрирование методом правых прямоугольников: " + Chr(13)

For i = 1 To n

otv = otv + CStr(E1(i, 1)) + " " + CStr(E1(i, 2)) + Chr(13)

Next

otv = otv + Chr(13)


i = 50 : j = 0

Do

If i < 1000 Then

i = i + 50 : j = j + 1

E2(j, 1) = i

E2(j, 2) = trap(Sa(1, 1), Sa(j, 1), h)

runge(Sa(1, 1), Sa(j, 1), h)

E2(j, 2) = E2(j, 2) + Rung

Else

i = i + 20 : j = j + 1

E2(j, 1) = i

E2(j, 2) = trap(Sa(1, 1), Sa(j, 1), h)

runge(Sa(1, 1), Sa(j, 1), h)

E2(j, 2) = E2(j, 2) + Rung

End If

Loop Until i = Sa(n, 1)

otv = otv + "Зависимость E(T), интегрирование методом трапеций: " + Chr(13)

For i = 1 To n

otv = otv + CStr(E2(i, 1)) + " " + CStr(E2(i, 2)) + Chr(13)

Next

vb = 0 : etk = 0

vb = Math.Abs((pr(Sa(1, 1), Sa(n, 1), h * kof) - pr(Sa(1, 1), Sa(n, 1), h * (kof ^ 2))) / (pr(Sa(1, 1), Sa(n, 1), h) - pr(Sa(1, 1), Sa(n, 1), h * kof)))

etk = (Math.Log(vb)) / Math.Log(kof)

otv = otv + " Порядок интегрир. методом правых прямоугольников P=" + CStr(etk) + Chr(13)

vb = 0 : etk = 0

vb = Math.Abs((trap(Sa(1, 1), Sa(n, 1), h * kof) - trap(Sa(1, 1), Sa(n, 1), h * (kof ^ 2))) / (trap(Sa(1, 1), Sa(n, 1), h) - trap(Sa(1, 1), Sa(n, 1), h * kof)))

etk = (Math.Log(vb)) / Math.Log(kof)

otv = otv + "Порядок интегрир. методом трапеций P=" + CStr(etk) + Chr(13)

Me.RichTextBox1.Text = Me.RichTextBox1.Text + otv

End Sub


Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim mh, mw, msx, msy, y1, y2, x1, x2, ms As Single

Dim max As Double

' Dim rez As String

Dim graph As Graphics = Me.PictureBox1.CreateGraphics

Dim pn As Pen = New Pen(Color.Gray, 1)

Dim pn1 As Pen = New Pen(Color.Gray, 1)

Me.PictureBox1.Refresh()

mh = CSng(Me.PictureBox1.Height) / 2

mw = CSng(Me.PictureBox1.Width) / 2

MS = CSng(Me.TextBox1.Text) ' корректирующие коэффициенты

max = E1(1, 2)

For i = 1 To n

If Math.Abs(E1(i, 2)) >= max Then

max = Math.Abs(E1(i, 2))

End If

Next

msx = mw / (max * ms / 5)

msy = mh / (max * ms * 2) ' Масштабные коэффициенты

graph.TranslateTransform(0, mh)

graph.DrawLine(New Pen(Brushes.Black, 1), 0, -mh * 2, 0, mh * 2) ' Рисовалки

graph.DrawLine(New Pen(Brushes.Black, 2), 0, 0, mw * 2, 0)

For i = 1 To n - 1

x1 = E1(i, 1) : y1 = -E1(i, 2)

x2 = E1(i + 1, 1) : y2 = -E1(i + 1, 2)

graph.DrawLine(pn, msx * x1, y1 * msy, msx * x2, y2 * msy)

Next

For i = 1 To n - 1

x1 = E2(i, 1) : y1 = -E2(i, 2)

x2 = E2(i + 1, 1) : y2 = -E2(i + 1, 2)

graph.DrawLine(pn1, msx * x1, y1 * msy, msx * x2, y2 * msy)

Next


End Sub

End Class








Чтобы не видеть здесь видео-рекламу достаточно стать зарегистрированным пользователем.
Чтобы не видеть никакую рекламу на сайте, нужно стать VIP-пользователем.
Это можно сделать совершенно бесплатно. Читайте подробности тут.