在form中加上label,picture和command控件,在代码窗口加入下面这些,然后运行.
Const Pi = 3.1415926535
Private Function DrawDot(Px, Py, Color)
Picture1.PSet (Px, Py), Color
End Function
Private Sub Command1_Click()
Picture1.DrawWidth = 1 '设置线条宽度
Picture1.Cls
'设定用户坐标系,坐标原点在Picture1中心
Picture1.Scale (-10, 10)-(10, -10)
Picture1.Line (-10, 0)-(10, 0), RGB(0, 0, 255)
Picture1.Line -(9.5, 0.5), RGB(0, 0, 255)
Picture1.Line (10, 0)-(9.5, -0.5), RGB(0, 0, 255)
Picture1.ForeColor = RGB(0, 0, 255)
Picture1.Print "X"
Picture1.Line (0, -10)-(0, 10), RGB(0, 0, 255)
Picture1.Line -(0.5, 9.5), RGB(0, 0, 255)
Picture1.Line (0, 10)-(-0.5, 9.5), RGB(0, 0, 255)
Picture1.CurrentX = -1
Picture1.CurrentY = 10
Picture1.Print "Y"
'画 Y 轴
For lin = -9 To 9
Picture1.Line (lin, 0)-(lin, 0.25)
'wor = PrintWord(lin - 0.5, -0.5, Str(lin))
Picture1.Line (0, lin)-(-0.25, lin)
If lin <> 0 Then
'wor = PrintWord(-0.9, lin, Str(lin))
End If
Next lin
Picture1.DrawWidth = 2
'Picture1.Refresh
'用For循环绘点,使其按正弦规律变化。
'步长小,使曲线比较平滑,还能形成动画效果
For a = -2 * Pi To 2 * Pi Step Pi / 6000
Dot = DrawDot(a, Sin(a) * 5, RGB(0, 255, 0))
Next a
Picture1.AutoRedraw = True
Label1.Caption = " 哈哈,这个表情怎么样.."
End Sub