图1设定界面
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/diannaorumen/)这些内容完成后,再点击控件工具箱中的命令按钮控件,同样用鼠标拖放的办法在幻灯片编辑窗口拖放出三个命令按钮。
命令按钮的代码编辑
选中第一个命令按钮,点击右键,在弹出的快捷菜单中选择属性命令,打开其属性设置对话框,点击Caption右侧属性栏,将其内容改为画坐标系(如图2)。用同样的方法将另外两个命令按钮的Caption属性修改为清空数据和清除图像。
图2设定按钮属性
选中[画坐标系]命令按钮,点击右键,在弹出的快捷菜单中选择查看代码命令,打开Microsoft Visual Basic编辑窗口,找到这样两行代码:
Private Sub CommandButton1_Click()
End Sub
在它们之间插入如下代码:
h = Val(TextBox1.Text)
k = Val(TextBox2.Text)
Length = Val(TextBox3.Text)
Number = Val(TextBox4.Text)
Dim xx
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/diannaorumen/)xx = 1
Do While xx Number
If xx Mod 5 = 0 Then
SlideShowWindows(1).View.DrawLine h + xx?Length, k - 7, h + xx?Length, k
SlideShowWindows(1).View.DrawLine h - xx?Length, k - 7, h - xx?Length, k
SlideShowWindows(1).View.DrawLine h, k - xx?Length, h + 7, k - xx?Length
SlideShowWindows(1).View.DrawLine h, k + xx?Length, h + 7, k + xx?Length
Else
SlideShowWindows(1).View.DrawLine h + xx?Length, k - 3, h + xx?Length, k
SlideShowWindows(1).View.DrawLine h - xx?Length, k - 3, h - xx?Length, k
SlideShowWindows(1).View.DrawLine h, k - xx?Length, h + 3, k - xx?Length
SlideShowWindows(1).View.DrawLine h, k + xx?Length, h + 3, k + xx?Length
End If
xx = xx + 1
Loop
SlideShowWindows(1).View.DrawLine h, k, h + xx?Length, k
"画x轴正半轴
SlideShowWindows(1).View.DrawLine h - xx?Length, k, h, k
"画x轴负半轴
SlideShowWindows(1).View.DrawLine h, k, h, k - xx?Length
"画y轴正半轴
SlideShowWindows(1).View.DrawLine h, k, h, k + xx?Length
"画y轴负半轴