跪求了!!!!!!!!!!!
急求cad下面的展点连线程序,源码!!!!! 谢谢,小弟真的跪求了! 你是要读取数据库中的坐标,然后再展点连线么?? <P>Dim cn As ADODB.Connection<BR>'创建ADO连接并打开<BR>Sub CreateConnection()<BR> Dim ConStr As String '连接字符串<BR> Set cn = New ADODB.Connection<BR> <BR> cn.CursorLocation = adUseClient<BR> cn.Provider = "Microsoft.Jet.OLEDB.4.0;"<BR> ConStr = "Data Source=你的数据库文件;"<BR> cn.Open ConStr<BR>End Sub</P><P><BR>' 从数据库中读取数据<BR>Public Sub ReadFromDB()<BR> ' 创建数据库连接<BR> Call CreateConnection<BR> <BR> ' 在line表中查询所有的记录<BR> Set rst = New ADODB.Recordset<BR> rst.CursorLocation = adUseClient<BR> rst.Open "SELECT DISTINCT * FROM line", cn, adOpenForwardOnly, _<BR> adLockBatchOptimistic, adCmdText<BR> rst.MoveFirst<BR> <BR> Dim i As Integer<BR> Dim pt1(0 To 2) As Double, pt2(0 To 2) As Double<BR> <BR> ' 使用查询得到的数据创建直线<BR> For i = 0 To rst.RecordCount - 1<BR> pt1(0) = rst.Fields("x1")<BR> pt1(1) = rst.Fields("y1")<BR> pt1(2) = 0<BR> pt2(0) = rst.Fields("x2")<BR> pt2(1) = rst.Fields("y2")<BR> pt2(2) = 0<BR> <BR> ThisDrawing.ModelSpace.AddLine pt1, pt2<BR> rst.MoveNext<BR> Next i<BR> <BR> 'rst.Close ' 关闭记录集,准备下一次使用<BR> <BR> ' 在line表中查询<BR> <BR> Set rst = New ADODB.Recordset<BR> rst.CursorLocation = adUseClient<BR> rst.Open "SELECT x1,y1 FROM line", cn, adOpenForwardOnly, _<BR> adLockBatchOptimistic, adCmdText<BR> rst.MoveFirst<BR> <BR> ' 使用表中的数据绘制圆<BR> For i = 0 To rst.RecordCount - 1<BR> pt1(0) = rst.Fields("x1")<BR> pt1(1) = rst.Fields("y1")<BR> pt1(2) = 0<BR> ThisDrawing.ModelSpace.Addpoint<BR> rst.MoveNext<BR> <BR> Next i<BR> 'rst.Close<BR> <BR> ThisDrawing.Application.Update<BR>End Sub</P>
<P>这个代码应该符合你的要求</P>
页:
[1]