找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 620|回复: 1

[VBA程序]:求高手帮我分析一下。。。

[复制链接]
发表于 2002-12-14 16:55:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Private Sub ComboBox1_Click()
Dim cn As Connection
Set cn = New Connection
cn.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=d:\cf.mdb;"

Dim cmd As New ADODB.Command
Set cmd.ActiveConnection = cn
cmd.CommandText = "select b,h,name from cf1 where name='" & ComboBox1.Text & "'"

Dim rst As New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenStatic, adLockBatchOptimistic


Do While Not rst.EOF
UserForm1.TextBox1.Text = rst("h")
UserForm1.TextBox2.Text = rst("b")
rst.MoveNext
Loop
rst.Clone


End Sub



Private Sub CommandButton1_Click()
UserForm1.Hide
Dim pt As Variant
pt = ThisDrawing.Utility.GetPoint(, "拾取插入点:")

h = Val(UserForm1.TextBox1.Text)
b = Val(UserForm1.TextBox2.Text)

Dim ax1(0 To 2) As Double
Dim ax2(0 To 2) As Double
Dim ax3(0 To 2) As Double
Dim ax4(0 To 2) As Double
ax1(0) = pt(0)
ax1(1) = pt(1)
ax1(2) = pt(2)
ax2(0) = pt(0) + b
ax2(1) = pt(1)
ax2(2) = pt(2)
ax3(0) = pt(0)
ax3(1) = pt(1) + h
ax3(2) = pt(2)
ax4(0) = pt(0) + b
ax4(1) = pt(1) + h
ax4(2) = pt(2)

Dim linea, lineb, linec, lined As AcadLine
Set linea = ThisDrawing.ModelSpace.AddLine(ax1, ax2)
Set lineb = ThisDrawing.ModelSpace.AddLine(ax2, ax3)
Set linec = ThisDrawing.ModelSpace.AddLine(ax3, ax4)
Set lined = ThisDrawing.ModelSpace.AddLine(ax4, ax1)

   
End Sub


Private Sub UserForm_Initialize()
ComboBox1.AddItem "10*20"
ComboBox1.AddItem "15*30"
ComboBox1.AddItem "20*40"
End Sub

执行以后出现这句提示:实时错误‘-2147217904(80040阿0)’:至少一个参数没有被指定值。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 181个

财富等级: 日进斗金

发表于 2002-12-15 15:10:19 | 显示全部楼层
Dim cmd As New ADODB.Command
Set cmd.ActiveConnection = cn
cmd.CommandText = "select b,h,name from cf1 where name='" & ComboBox1.Text & "'"

Dim rst As New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenStatic, adLockBatchOptimistic
上面的Command对象不必声明,可直接用Recordset对象来获取查询记录,如下:
rst.Open select b,h,name from cf1 where name='" & ComboBox1.Text & "'", cn, adOpenStatic, adLockBatchOptimistic
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-24 07:06 , Processed in 0.409856 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表