我只会用vb绘制一次函数图象怎么样画二次的代码类似于Private Sub Cmd1_Click()k = Val(InputBox("k"))b = Val(InputBox("b"))Picture1.ClsPicture1.ScaleMode = 3Picture1.Scale (-150, 150)-(150, -150)Picture1.DrawWidth = 1Picture1.Line
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 00:50:19
我只会用vb绘制一次函数图象怎么样画二次的代码类似于Private Sub Cmd1_Click()k = Val(InputBox("k"))b = Val(InputBox("b"))Picture1.ClsPicture1.ScaleMode = 3Picture1.Scale (-150, 150)-(150, -150)Picture1.DrawWidth = 1Picture1.Line
我只会用vb绘制一次函数图象怎么样画二次的
代码类似于
Private Sub Cmd1_Click()
k = Val(InputBox("k"))
b = Val(InputBox("b"))
Picture1.Cls
Picture1.ScaleMode = 3
Picture1.Scale (-150, 150)-(150, -150)
Picture1.DrawWidth = 1
Picture1.Line (-150, 0)-(150, 0), RGB(0, 0, 255)
Picture1.Line (0, 150)-(0, -150), RGB(0, 0, 255)
Picture1.CurrentX = 1
Picture1.CurrentY = -1
Picture1.DrawWidth = 2
For x = -140 To 140
Picture1.PSet (x, k * x + b), RGB(255, 0, 0)
Next x
End Sub
写的简单点,最好加个注释
我只会用vb绘制一次函数图象怎么样画二次的代码类似于Private Sub Cmd1_Click()k = Val(InputBox("k"))b = Val(InputBox("b"))Picture1.ClsPicture1.ScaleMode = 3Picture1.Scale (-150, 150)-(150, -150)Picture1.DrawWidth = 1Picture1.Line
Const pi = 3.14159265359879
Dim x
Private Sub Command1_Click()
'首先清除picture1内的图形
Picture1.Cls
'Scale方法设定用户坐标系,坐标原点在Picture1中心
Picture1.ScaleMode = 0
Picture1.ScaleMode = 3
Picture1.Scale (-20,20)-(20,-20)
'设置绘线宽度
Picture1.DrawWidth = 1
'绘坐标系的X轴及箭头线
Picture1.Line (-20,0)-(20,0),vbBlue
Picture1.Line (18,1)-(20,0),vbBlue
Picture1.Line -(18,-1),vbBlue
Picture1.ForeColor = vbBlue
Picture1.Print "X"
'绘坐标系的Y轴及箭头线
Picture1.Line (0,20)-(0,-20),vbBlue
Picture1.Line (1,18)-(0,20),vbBlue
Picture1.Line -(-1,18),vbBlue
Picture1.Print "Y"
'指定位置显示原点O
Picture1.CurrentX = 1
Picture1.CurrentY = -1
Picture1.Print "O"
'重设绘线宽度
Picture1.DrawWidth = 2
'用For循环绘点,使其按抛物线规律变化.步长值很小,使之形成动画效果
a = Val(InputBox("a"))
b = Val(InputBox("b"))
c = Val(InputBox("c"))
For x = -20 To 10 Step pi / 6000
Picture1.PSet (x,a * x ^ 2 / 5 + b * x - c),vbRed
Next x
'指定位置显示描述文字
Picture1.CurrentX = pi / 2
Picture1.CurrentY = -7
Picture1.ForeColor = vbBlack
Picture1.Print "抛物线示意"
End Sub