Imports System.IO Module Module1 Sub Main() Dim auc As Double = 0 Dim ba As Double = 0.45 Dim cl As Double = 4 Dim dose As Double = 0 Dim f(3) As Double Dim g As Double = 0 Dim h As Double = 0.01 Dim i As Integer Dim ka As Double = 0.07 Dim kn1(3), kn2(3), kn3(3), kn4(3) As Double Dim k12 As Double = 0.028 Dim k21 As Double = 0.0088 Dim pc As Double Dim q As Double = 10 Dim rr As Double = 1.7 / 60 Dim tdose As Double = 0 Dim vd As Double = 600 Dim w As Double = 75.3 Dim X As Double = 0 Dim xmax As Double = 1440 Dim Y(3) As Double Dim yn(3) As Double For i = 1 To 3 Y(i) = 0 Next Dim file As StreamWriter file = My.Computer.FileSystem.OpenTextFileWriter( "C:\Users\Kevin C. Johnson\crnd.txt", False) Start: If X >= h Then dose = rr * h tdose = tdose + dose pc = Y(2) * 1000000 / (vd * w) auc = auc + pc * h If g < h Then file.Write(X.ToString("0.00E+0")) If g < h Then file.Write(" ") If g < h Then file.WriteLine(pc.ToString("0.00E+0")) g = g + h If g > q - h / 2 Then g = 0 For i = 1 To 3 eq(f, rr, ka, Y, ba, cl, vd, k12, k21) yn(i) = Y(i) kn1(i) = f(i) X = X + h / 2 Y(i) = yn(i) + kn1(i) * h / 2 eq(f, rr, ka, Y, ba, cl, vd, k12, k21) kn2(i) = f(i) Y(i) = yn(i) + kn2(i) * h / 2 eq(f, rr, ka, Y, ba, cl, vd, k12, k21) kn3(i) = f(i) X = X + h / 2 Y(i) = yn(i) + kn3(i) * h eq(f, rr, ka, Y, ba, cl, vd, k12, k21) kn4(i) = f(i) Y(i) = yn(i) + h * (kn1(i) + 2 * kn2(i) + 2 * kn3(i) + kn4(i)) / 6 X = X - h Next X = X + h If X < xmax + h Then GoTo Start file.Close() End Sub Sub eq(ByRef f() As Double, ByRef rr As Double, ByRef ka As Double, ByRef Y() As Double, ByRef ba As Double, ByRef cl As Double, ByRef vd As Double, ByRef k12 As Double, ByRef k21 As Double) f(1) = rr - ka * Y(1) f(2) = ka * Y(1) * ba - (cl / vd + k12) * Y(2) + k21 * Y(3) f(3) = k12 * Y(2) - k21 * Y(3) End Sub End Module