Вообще программа создается через exel(по заданию),через него вызывается VBA, где и создается программа.
Текст всей программы такой:
- Код: Выделить всё
Private Sub Command1_Click()
Lz = Val(Text1): P = Val(Text2): C = Val(Text3)
TD = Val(Text4): STotn = Val(Text5): Nr = Val(Text6)
For j = 1 To 4: MTobs(j) = Val(Text7(j - 1)): Next j
Call Model4
End Sub
Private Sub Command2_Click()
Text8 = "": Text9 = ""
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Text1_Change()
End Sub
Private Sub Text10_Change()
End Sub
Private Sub Text11_Change()
End Sub
Private Sub Text12_Change()
End Sub
Public MTobs(4), TH(4), TK(4)
Public Mprof As Double, Cprof As Double, Sum2 As Double
Public SNM As Double, SigProf As Double
Public Lz, P, C, TD, STotn, Nr
Public Ir, Nz, Tz0, Nobs, i, j, z, Tz, N, Tobs, Sz, Min
Public Max, SMT, Fact
Const K = 4
Public Sub Model7()
Randomize
Mprof = 0
Sum = 0
For Ir = 1 To Nr
Nz = 0: Tz0 = 0: Nobs = 0
For j = 1 To K: TK(j) = 0: Next j
Do
z = Rnd
Tz = Tz0 - Log(z) / Lz
Tz0 = Tz
If Tz > TD Then Exit Do
Nz = Nz + 1
For j = 1 To K
If Tz > TK(j) Then TH(j) = Tz Else TH(j) = TK(j)
N = NORM
Tobs = MTobs(j) * (1 + N * STotn)
TK(j) = TH(j) + Tobs
If TK(j) > TD Then Exit Do
Tz = TK(j)
Next j
Nobs = Nobs + 1
Loop
Prof = P * Nobs - C
Mprof = Mprof + Prof
Sum2 = Sum2 + Prof * Prof
Next Ir
Cprof = Mprof / Nr
Disp = (Sum2 - Nr * Cprof * Cprof) / (Nr - 1)
If Disp > 0 Then SigProf = Sqr(Disp) Else SigProf = 0
Gprof = Cprof - 1.28 * SigProf
Call Factor
Form1.Text8 = Format$(Fact, "0.000")
Form1.Text9 = Format$(Gprof, "#####")
End Sub
Function NORM()
Sz = 0
For i = 1 To 12
z = Rnd: Sz = Sz + z
Next i
NORM = Sz - 6
End Function
Public Sub Factor()
Min = MTobs(1): Max = MTobs(1): SMT = 0
For f = 1 To K
SMT = SMT + MTobs(f)
If MTobs(f) > Max Then Max = MTobs(f)
If MTobs(f) < Min Then Min = MTobs(f)
Next
Fact = (Max - Min) / SMT
End Sub
Private Sub Text2_Change()
End Sub
Private Sub Text3_Change()
End Sub
Private Sub Text4_Change()
End Sub
Private Sub Text5_Change()
End Sub
Private Sub Text6_Change()
End Sub
Private Sub Text7_Change()
End Sub
Private Sub Text8_Change()
End Sub
Private Sub Text9_Change()
End Sub
[Viper] :: Пользуемся тегами форматирования кода!