перевод кода из Vb 6 в Vb .net

  • Автор темы kamil
  • Дата начала
K

kamil

Гость
#1
Код:
Dim x(), e(), em(), o() As Single
Private i, n As Integer
Private x0, xk, y0, h, miny, maxy, minx, maxx As Single
Function f(x, y) As Single
p = Log(x) / Log(2.718282)
f = (y ^ 2 * p - y) / x
End Function

Private Sub Eiler()
ReDim x(n + 1)
ReDim e(n + 1)
e(0) = y0
For i = 0 To n
x(i) = Round(x0 + (i * h), 3)
e(i + 1) = Round(e(i) + h * f(x(i), e(i)), 3)
Next i
End Sub

Private Sub RungeK4()
ReDim x(n + 1)
ReDim em(n + 1)
em(0) = y0
For i = 0 To n
x(i) = Round(x0 + i * h, 3)
k1 = h * f(x(i), em(i))
k2 = h * f(x(i) + (h / 2), em(i) + (k1 / 2))
k3 = h * f(x(i) + (h / 2), em(i) + (k2 / 2))
k4 = h * f(x(i) + h, em(i) + k3)
k = (k1 + 2 * k2 + 2 * k3 + k4) / 6
em(i + 1) = Round(em(i) + k, 3)
Next i
End Sub

Private Sub Obhee()
ReDim x(n + 1)
ReDim o(n + 1)
maxy = y0
miny = y0
maxx = x0
minx = x0
p = Log(x0) / Log(2.718282)
c = (1 / (x0 * y0)) - (1 / x0) - (p / x0)
For i = 0 To n
x(i) = Round(x0 + i * h, 3)
p = Log(x(i)) / Log(2.718282)
o(i) = (1 / (1 + p + c * x(i)))
Next i
End Sub

Private Sub Command1_Click()
x0 = Val(Text1.Text)
y0 = Val(Text2.Text)
xk = Val(Text3.Text)
h = Val(Text4.Text)
n = Round((xk - x0) / h)
MSFlexGrid1.Cols = 4
MSFlexGrid1.Rows = n + 2
MSFlexGrid1.TextMatrix(0, 0) = "x"
MSFlexGrid1.TextMatrix(0, 1) = "Общее решение"
MSFlexGrid1.TextMatrix(0, 2) = "Эйлер"
MSFlexGrid1.TextMatrix(0, 3) = "Рунге-Кутт"

Eiler
RungeKutta
Obhee
For i = 0 To n
MSFlexGrid1.TextMatrix(i + 1, 0) = Str(x(i))
MSFlexGrid1.TextMatrix(i + 1, 1) = Str(o(i))
MSFlexGrid1.TextMatrix(i + 1, 2) = Str(e(i))
MSFlexGrid1.TextMatrix(i + 1, 3) = Str(em(i))
Next i
minx = x(0)
maxx = x(n)
miny = o(0)
maxy = o(n)
If e(n) > o(n) Then maxy = e(n)
If em(n) > o(n) Then maxy = em(n)
If e(n) > em(n) Then maxy = e(n)
Label10.Caption = Str(miny)
Label11.Caption = Str(maxy)
Label8.Caption = Str(minx)
Label12.Caption = Str(maxx)
Picture1.Cls
kx = (4000 - 700) / (xk - x0)
ky = (5000 - 6000) / (maxy - miny)
For i = 0 To n - 1
z1 = (720 + (x(i) - x0) * kx)
z2 = (1000 - (e(i) - miny) * ky)
z3 = (720 + (x(i + 1) - x0) * kx)
z4 = (1000 - (e(i + 1) - miny) * ky)
Picture1.Line (z1, z2)-(z3, z4), vbBlue
Next i
For i = 0 To n - 1
z1 = (720 + (x(i) - x0) * kx)
z2 = (1000 - (em(i) - miny) * ky)
z3 = (720 + (x(i + 1) - x0) * kx)
z4 = (1000 - (em(i + 1) - miny) * ky)
Picture1.Line (z1, z2)-(z3, z4), vbGreen
Next i
For i = 0 To n - 1
z1 = (720 + (x(i) - x0) * kx)
z2 = (1000 - (o(i) - miny) * ky)
z3 = (720 + (x(i + 1) - x0) * kx)
z4 = (1000 - (o(i + 1) - miny) * ky)
Picture1.Line (z1, z2)-(z3, z4), vbRed
Next i
End Sub

Private Sub Command2_Click()
End
End Sub

кто сможет переведите код в vb .net