Daichaozheng
第13楼2014/08/17
改进后的程序如下:
Dim x As Double, y(301) As Double, sh As Double, ch As Double, n As Integer, fw As Double, fw1 As Double
Private Sub Command1_Click()
fw = Val(Text1.Text)
fw1 = fw / 150
n = 1
For i = 1 To 301
If i = 150 Then GoTo 10
x = -fw + i * fw1
sh = (Exp(x) - Exp(-x)) / 2
ch = (Exp(x) + Exp(-x)) / 2
y(i) = (2 * x ^ 3 * sh ^ 2 + 2 * x * sh ^ 2 + x * ch ^ 2 * sh ^ 2 + 3 * ch * sh ^ 3 - 6 * x ^ 3 * ch ^ 2 - x * sh ^ 4) / x ^ 5 / sh ^ 4
10 Next i
If y(149) > y(151) Then y(0) = y(149) Else y(0) = y(151)
If 2 * y(149) - y(148) < 2 * y(151) - y(152) Then y(150) = 2 * y(149) - y(148) Else y(150) = 2 * y(151) - y(152)
y(150) = (y(150) + y(0)) / 2
a = 32 / 315
Text2.Text = Str$(a)
Text3.Text = Str$(y(150))
Picture1.Cls
Picture1.Scale (0, 0)-(100, 5000)
For i = 1 To 5000
a = 256 - i / 10
If a < 0 Then a = 0
Picture1.Line (0, i)-(100, i), RGB(0, 0, a)
Next i
Picture1.Scale (-1.1 * Val(Text1.Text), 0.13)-(1.1 * Val(Text1.Text), -0.02)
Picture1.Line (-Val(Text1.Text), 0)-(Val(Text1.Text), 0), RGB(256, 256, 256)
Picture1.Line (0, 0)-(0, 0.12), RGB(256, 256, 256)
For i = 0 To 0.115 Step 0.01
Picture1.Line (-0.08, i)-(0.08, i), RGB(256, 256, 256)
Next i
For i = 0 To 0.115 Step 0.001
Picture1.Line (-0.03, i)-(0.03, i), RGB(256, 256, 256)
Next i
For i = 0 To 0.115 Step 0.01
Picture1.CurrentX = 0.02
Picture1.CurrentY = i + 0.0035
Picture1.Print i
Next i
For i = 1 To 300
X1 = -fw + i * fw1
X2 = X1 + fw1
Y1 = y(i)
Y2 = y(i + 1)
Picture1.Line (X1, Y1)-(X2, Y2), RGB(128, 256, 256)
Next i
SavePicture Picture1.Image, "c:\tu.jpeg"
End Sub
Private Sub end_Click()
End
End Sub
Private Sub Form_Activate()
Picture1.Scale (0, 0)-(100, 5000)
For i = 1 To 5000
a = 256 - i / 10
If a < 0 Then a = 0
Picture1.Line (0, i)-(100, i), RGB(0, 0, a)
Next i
End Sub
放大图形的上部如下: