给你个参考:
'加入一个Picture控件和1个按钮
Private Sub Command1_Click()
Picture1Cls
axis Picture1
For i = -9 To 9 Step 0005
Picture1PSet (i, MyFun(i))
Next i
End Sub
Private Function MyFun(ByVal X As Double) '这里定义函数
Dim Y As Double
Y = Sin(X)
MyFun = Y
End Function
Private Sub Form_Load()
Show
Picture1Scale (-10, 10)-(10, -10)
Picture1BackColor = vbWhite
axis Picture1
End Sub
Private Sub axis(obj As Object)
'x轴
objLine (-objScaleWidth / 2 + 05, 0)-(objScaleWidth / 2 - 05, 0)
objLine -(objScaleWidth / 2 - 1, 02)
objLine (objScaleWidth / 2 - 05, 0)-(objScaleWidth / 2 - 1, -02)
'y轴
objLine (0, objScaleHeight / 2 + 05)-(0, -objScaleHeight / 2 - 05)
objLine -(-02, -objScaleHeight / 2 - 1)
objLine (0, -objScaleHeight / 2 - 05)-(02, -objScaleHeight / 2 - 1)
objFontSize = 9
'刻度
For cx = -9 To 9 Step 3
objLine (cx, 0)-(cx, 02)
If cx <> 0 Then
objCurrentX = cx - 03
objCurrentY = -02
objPrint cx
End If
Next
For cy = -9 To 9 Step 3
objLine (0, cy)-(02, cy)
If cy <> 0 Then
objCurrentX = -08
objCurrentY = cy + 02
objPrint cy
End If
Next
objCurrentX = -05
objCurrentY = -02
objFontSize = 12
objPrint "O" '
End Sub
你要先把AutoCad的对象模型搞懂
在Cad的帮助里有相关的内容
先打开Cad,然后运行下面的代码
Dim acadapp As Object
Dim acaddoc As Object
Dim mspace As Object
Set acadapp = GetObject(, "autocadapplication")
Set acaddoc = acadappactivedocument
Set mspace = acaddocmodelspace
Dim pnt(2) As Double
Dim r As Double
r = 10
mspaceaddcircle pnt, r
以上就是关于求vb实现画图程序代码全部的内容,包括:求vb实现画图程序代码、如何在VB中调用AutoCAD的画图功能、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)