求助!我编的程序,有问题!!给点修改,谢谢
我们的课程设计,做了好久,还是没有做到满意,三角波不行呀!望高手给点建议呀,帮忙改一下了,明天久要交了!呜呜~~~~
Const pi = 3.14159
Dim a
Dim m
Dim k
Dim wor
Dim d As Double, f As Double
Sub XY() '建立直角坐标系
Picture1.Cls
Picture1.ScaleMode = 0
Picture1.ScaleMode = 3
Picture1.Scale (-10, 10)-(10, -10) '设置绘线宽度
Picture1.DrawWidth = 1 '绘坐标系的X轴及箭头线
Picture1.Line (-10, 0)-(10, 0), vbBlue
Picture1.Line (9, 0.5)-(10, 0), vbBlue
Picture1.Line -(9, -0.5), vbBlue
Picture1.ForeColor = vbBlue
Picture1.Print "X/t" '绘坐标系的Y轴及箭头线
Picture1.Line (0, 10)-(0, -10), vbBlue
Picture1.Line (0.5, 9)-(0, 10), vbBlue
Picture1.Line -(-0.5, 9), vbBlue
Picture1.Print "Y/V"
Picture1.CurrentX = -0.5 '指定Y标值
Picture1.CurrentY = -0.2
Picture1.Print "O"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 1
Picture1.Print "1"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 2
Picture1.Print "2"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 3
Picture1.Print "3"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 4
Picture1.Print "4"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 5
Picture1.Print "5"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 6
Picture1.Print "6"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 7
Picture1.Print "7"
Picture1.CurrentX = -0.5
Picture1.CurrentY = 8
Picture1.Print "8"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -1
Picture1.Print "-1"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -2
Picture1.Print "-2"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -3
Picture1.Print "-3"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -4
Picture1.Print "-4"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -5
Picture1.Print "-5"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -6
Picture1.Print "-6"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -7
Picture1.Print "-7"
Picture1.CurrentX = -0.5
Picture1.CurrentY = -8
Picture1.Print "-8"
Picture1.CurrentX = 1 '指定X标值
Picture1.CurrentY = -0.5
Picture1.Print "1"
Picture1.CurrentX = 2
Picture1.CurrentY = -0.5
Picture1.Print "2"
Picture1.CurrentX = 3
Picture1.CurrentY = -0.5
Picture1.Print "3"
Picture1.CurrentX = 4
Picture1.CurrentY = -0.5
Picture1.Print "4"
Picture1.CurrentX = 5
Picture1.CurrentY = -0.5
Picture1.Print "5"
Picture1.CurrentX = 6
Picture1.CurrentY = -0.5
Picture1.Print "6"
Picture1.CurrentX = 7
Picture1.CurrentY = -0.5
Picture1.Print "7"
Picture1.CurrentX = 8
Picture1.CurrentY = -0.5
Picture1.Print "8"
Picture1.CurrentX = -1
Picture1.CurrentY = -0.5
Picture1.Print "-1"
Picture1.CurrentX = -2
Picture1.CurrentY = -0.5
Picture1.Print "-2"
Picture1.CurrentX = -3
Picture1.CurrentY = -0.5
Picture1.Print "-3"
Picture1.CurrentX = -4
Picture1.CurrentY = -0.5
Picture1.Print "-4"
Picture1.CurrentX = -5
Picture1.CurrentY = -0.5
Picture1.Print "-5"
Picture1.CurrentX = -6
Picture1.CurrentY = -0.5
Picture1.Print "-6"
Picture1.CurrentX = -7
Picture1.CurrentY = -0.5
Picture1.Print "-7"
Picture1.CurrentX = -8
Picture1.CurrentY = -0.5
Picture1.Print "-8"
Picture1.CurrentX = -9
Picture1.CurrentY = -0.5
Picture1.Print "-9"
Picture1.CurrentX = -10
Picture1.CurrentY = -0.5
Picture1.Print "-10"
End Sub
Private Sub Command1_Click() '画正弦曲线
d = Text1
f = Text2
k = Text3
XY
Picture1.DrawWidth = k '重设绘线宽度
'用For循环绘点,使其按正弦规律变化。步长值很小,使其形成动画效果
For a = -10 To 9 Step pi / 6000
Picture1.PSet (a, d * Sin(f * a * 6)), vbRed
Next
'指定位置显示描述文字
Picture1.CurrentX = pi / 2
Picture1.CurrentY = -7
Picture1.ForeColor = vbBlack
Picture1.Print "正弦波"
End Sub
Private Sub Command2_Click()
d = Text1
f = Text2
k = Text3
XY
Picture1.DrawWidth = k '重设绘线宽度
For X = -10 To 9 Step pi / 6000
m = Sin(2 * pi * f * X + q)
If m > 0 Then Picture1.PSet (X, d), vbBlue
If m < 0 Then Picture1.PSet (X, -d)
Next
Picture1.CurrentX = pi / 2
Picture1.CurrentY = -7
Picture1.ForeColor = vbBlack
Picture1.Print "矩形波"
End Sub
Private Sub Command3_Click()
d = Text1
f = Text2
k = Text3
XY
Picture1.DrawWidth = k '重设绘线宽度
For X = -10 To 9 Step pi / 6000
m = Sin(2 * pi * f * X)
If m > 0 Then
w = w + pi / 6000
Else
w = w - pi / 6000
End If
Picture1.PSet (X, d * w), vbGreen
Next
Picture1.CurrentX = pi / 2
Picture1.CurrentY = -7
Picture1.ForeColor = vbBlack
Picture1.Print "三角波"
End Sub
Private Sub Command4_Click()
End
End Sub