Dim xStart As Double, yStart As Double Dim x As Double Dim stopp As Boolean Private Sub Form_click() stopp = Not stopp x = 0 Picture1.ScaleMode = 3 Picture1.Line (0, 100)-(Picture1.Width, 100) Picture1.Line (0, 0)-(0, Picture1.Height) End SubPrivate Sub Form_Load() x = 0 stopp = False Picture1.ScaleMode = 3 xStart = 0: yStart = 100 End SubPrivate Sub Picture1_Paint() For x = 1 To Picture1.ScaleWidth Step 0.01 If stopp Then Exit Sub DoEvents Picture1.PSet (CDbl(xStart + Log(x)), CDbl(yStart - 100 * Sin(2000 * 3.14159 * x))), vbRed Next x End Sub
For X = 0 To 200 Step 0.1 TmpStr = Replace(UCase$(MathStr), "X", X) '替换掉原公式中的值 Y = ScriptControl1.Eval(TmpStr) '根据表达式计算值. '坐标原点是500,500 Picture1.CurrentX = X * 30 Picture1.CurrentY = 2000 + -Y * 30 '注意,电脑的Y坐标与数学坐标是相反的. Picture1.Print "." Next End Sub
Dim x As Double
Dim stopp As Boolean
Private Sub Form_click()
stopp = Not stopp
x = 0
Picture1.ScaleMode = 3
Picture1.Line (0, 100)-(Picture1.Width, 100)
Picture1.Line (0, 0)-(0, Picture1.Height)
End SubPrivate Sub Form_Load()
x = 0
stopp = False
Picture1.ScaleMode = 3
xStart = 0: yStart = 100
End SubPrivate Sub Picture1_Paint()
For x = 1 To Picture1.ScaleWidth Step 0.01
If stopp Then Exit Sub
DoEvents
Picture1.PSet (CDbl(xStart + Log(x)), CDbl(yStart - 100 * Sin(2000 * 3.14159 * x))), vbRed
Next x
End Sub
用这条更明显
程序你自己编吧.
Option Explicit
Public Y As Double
Public X As Double
'引用
Private Sub Command1_Click()
Dim MathStr As String
Dim TmpStr As String
On Error Resume Next
MathStr = "LOG(X)" '定义一个数学函数,可以能过TEXTBOX输入,但是只能有一个变量X.还要注意调整下面FOR循环中的范围.例如:1/X.要保证X>0.
For X = 0 To 200 Step 0.1
TmpStr = Replace(UCase$(MathStr), "X", X) '替换掉原公式中的值
Y = ScriptControl1.Eval(TmpStr) '根据表达式计算值.
'坐标原点是500,500
Picture1.CurrentX = X * 30
Picture1.CurrentY = 2000 + -Y * 30 '注意,电脑的Y坐标与数学坐标是相反的.
Picture1.Print "."
Next
End Sub