⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autocad vba初级教程 (第三课 程序的调试和保存) -- stef[cad cae c vb matlab] -- 编程爱好者blog.htm

📁 cad二次开发中介绍vba
💻 HTM
📖 第 1 页 / 共 2 页
字号:
              <TR>
                <TD class=tb_title height=20>BLOG介绍</TD></TR>
              <TR>
                <TD class=tb_content 
                  height=20>我是小小市民<BR>CAD&nbsp;CAE&nbsp;VB&nbsp;MATLAB&nbsp;爱好者<BR>name:zeng&nbsp;tian&nbsp;wei<BR></TD></TR>
              <TR>
                <TD class=tb_title height=20>文章类别</TD></TR>
              <TR>
                <TD class=tb_content height=20>·<A class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=4510">[C]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=402">[VB]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=4511">[WEB]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=590">[CAE]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=398">[CAD]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=406">[文化]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=617">[红客]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=4506">[Ansys]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=4507">[PRO/E]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=2201">[Matlab]</A><BR>·<A 
                  class=a1 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894&amp;columnid=4509">[系统病毒]</A><BR>·<A 
                  href="http://www.programfan.com/blog/blog.asp?blogid=894">所有文章</A></TD></TR>
              <TR>
                <TD class=tb_title height=20>最新评论</TD></TR>
              <TR>
                <TD class=tb_content height=20>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=20255#comment" 
                  target=_blank>&lt;a&nbsp;href=&amp;nbs</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=11365#comment" 
                  target=_blank>把我的收集贡献给大家:http:</A><BR>·<A 
                  href="http://www.programfan.com/blog/article.asp?id=9254#comment" 
                  target=_blank>我是个新手希望和大家讨论也想和大家学习有</A><BR></TD></TR>
              <TR>
                <TD class=tb_title height=20>最新留言</TD></TR>
              <TR>
                <TD class=tb_content height=20>·<A 
                  href="http://www.programfan.com/blog/guestbook.asp?blogid=894#3393">疫情通報&nbsp;&nbsp;</A><BR>·<A 
                  href="http://www.programfan.com/blog/guestbook.asp?blogid=894#1001">&nbsp;&lt;a&nbsp;hre</A><BR>·<A 
                  href="http://www.programfan.com/blog/guestbook.asp?blogid=894#473">您好我最近在做CAD文件的信息提</A><BR>&nbsp;&nbsp;&gt;<A 
                  href="http://www.programfan.com/blog/guestbook.asp?blogid=894"><B>填写留言</B></A>&lt;</TD></TR>
              <TR>
                <TD class=tb_title height=20>收藏夹</TD></TR>
              <TR>
                <TD class=tb_content height=20>·<A 
                  href="http://www.808cn.com/" target=_blank>电子爱好者</A><BR>·<A 
                  href="http://www.programfan.com/" 
                  target=_blank>编程爱好者网站</A><BR>·<A 
                  href="http://www.cnooc.com.cn/" 
                  target=_blank>中国海洋石油总公司</A><BR>·<A 
                  href="http://www.xysb.com/bbs/" 
                  target=_blank>梦想家园技术论坛</A><BR>·<A 
                  href="http://www.sjzj.com.cn/" 
                  target=_blank>网博学院&nbsp;</A><BR>·<A 
                  href="http://www.downcode.com/" target=_blank>源网易</A><BR>·<A 
                  href="http://www.career-edu.cn/" 
                  target=_blank>全人生涯规划网</A><BR>·<A href="http://www.sccas.cn/" 
                  target=_blank>并行计算专业委员会</A><BR>·<A 
                  href="http://www.sciei.com/" 
                  target=_blank>super科研中国</A><BR>·<A 
                  href="http://www.petrost.com/" 
                  target=_blank>石油科学与技术论坛</A><BR>·<A 
                  href="http://ip38.com/color/" 
                  target=_blank>网页颜色代码对照表</A><BR>·<A 
                  href="http://www.cnpc.com.cn/th/" 
                  target=_blank>我的工作单位</A><BR>·<A 
                  href="http://blog.programfan.com/" 
                  target=_blank>BLOG</A><BR>·<A href="http://swpi_ty.51.com/" 
                  target=_blank>装备中国石油</A><BR></TD></TR>
              <TR>
                <TD class=tb_title height=20>BLOG 统计</TD></TR>
              <TR>
                <TD class=tb_content 
                  height=20>&nbsp;·创建于:2005-6-7<BR>&nbsp;·共<SPAN 
                  style="COLOR: #ff0000">202</SPAN>篇文章<BR>&nbsp;·共<SPAN 
                  style="COLOR: #ff0000">3</SPAN>条留言<BR>&nbsp;·共<SPAN 
                  style="COLOR: #ff0000">43</SPAN>条评论<BR>&nbsp;·访问统计:<SPAN 
                  style="COLOR: #ff0000">173056<BR><A 
                  href="http://www.programfan.com/blog/rss.asp?author=ztw"><IMG 
                  src="Autocad VBA初级教程 (第三课 程序的调试和保存) -- STEF[CAD&nbsp;CAE&nbsp;C&nbsp;VB&nbsp;MATLAB] -- 编程爱好者BLOG.files/rss2.gif" 
                  border=0></A></SPAN></TD></TR></TBODY></TABLE></TD>
          <TD class=tb_top vAlign=top width=556>
            <DIV 
            style="MARGIN-LEFT: 10px; WIDTH: 95%; WORD-BREAK: break-all; WORD-WRAP: break-word">
            <DIV 
            style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: #ff0000; TEXT-ALIGN: center"><BR>Autocad 
            VBA初级教程 (第三课 程序的调试和保存)</DIV>
            <DIV align=center>点击数:671&nbsp;&nbsp;&nbsp;&nbsp;发布日期:2006-1-3 
            7:11:00&nbsp;&nbsp;<BR><A title="保存至编程爱好者收藏夹 myweb.pfan.cn" 
            href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(myweb=window.open('http://www.programfan.com/club/mywebedit.asp?title='+escape(d.title)+'&amp;url='+escape(d.location.href),'myweb','scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes'));">【收藏】</A>&nbsp;<A 
            href="http://www.programfan.com/blog/article.asp?id=9251#comment">【评论】</A>&nbsp;<A 
            href="javascript:window.print()">【打印】</A>&nbsp;<A 
            href="http://bbs.programfan.com/" 
            target=_blank>【编程爱好者论坛】</A>&nbsp;<A 
            href="javascript:window.close()">【关闭】</A><BR></DIV>
            <DIV style="TEXT-ALIGN: right"><BR>&nbsp;</DIV>
            <DIV 
            style="WIDTH: 520px; WORD-BREAK: break-all; WORD-WRAP: break-word">
            <DIV id=td_content><FONT id=zoom style="FONT-SIZE: 14px"><FONT 
            size=3></FONT>&nbsp; 
            <P>人非圣贤,孰能无过,初学者在编写复杂程序时往往会出现一些意想不到的错误,所以程序的调试显得尤为重要,随着学习的深入,以后我们需要经常进行程序调试。事实上,对于那些资深程序员来说,调试程序也是一项不可或缺的重要工作。</P>
            <P>首先,在程序输入阶段,应该充分利用VBA编辑器的智能功能。当你在写代码时,输入一些字母后,编辑器可以自动列出合适的语句、对象、函数供你选择,可以用上下键选择,然后按TAB键(它位于“Q”键左边)确认。当输入一个回车符后程序会自动对这条语句进行分析,如果出现错误就会提示。<BR>我们经常碰到的麻烦是程序的运行结果和预计的不一样,一般我会这样做:首先要想一想可能是哪一个变量有问题,然后去监视这个变量(或表达式),在程序合适的位置设置断点,这样可以使程序停下来看一看这个变量有没有按照我的设想在变化。下面我举一个简单的例子,先看源代码:<BR>sub 
            test()<BR>for i=2 to 4 step 0.6<BR>next i<BR>end 
            sub<BR>这是一个非常简单的循环,每一次循环i便会增加0.6,当循环3次后i值就变为4.4,但问题是每一次循环时i值变为多少?<BR>第一步:在菜单中选“调试”—“添加监视”,在表达试中填“i”,点击确定,这时你会看到临视窗口中会多一行。<BR>第二步:把光标移到代码窗口中的“next 
            i”行,按一下“F9”,于是每当程序运行到这里时就会暂停了。<BR>好,一切就绪,请按F5执行程序,在监视窗口中C值立刻变为2,再按F5继续,C值为2.6,再按几次F5,直到程序结束,这样我们就成功监视了C值的变化。<BR>第三步:在next 
            i行再按一次F9,清除断点。监视的表达式的右键菜单选择“删除监视”。<BR>另外,还可以用“逐语句”、“逐过程”、“运行到光标处”等方法进行调试,这些都在调试菜单中,操作比较简单,请读者自行领悟。</P>
            <P>到目前为止,我们所做的工程都是“嵌入式工程”,它只是嵌入在当前的Autocad图形文件中, 
            以后打开这个文件时代码才会加载,如果别的dwg文件也要使用,那就需要把代码导出为.bas文件,供其他dwg文件导入。在VBA编辑器的“文件”菜单中有这两个功能,一试便知。<BR>ACAD 
            VBA还有一种工程叫“通用式工程”,只要进入ACAD就可以运行,程序可以在不同用户、不同的图形文件中共享,但是由于VBA功能太强,有时候会出现一些意想不到的事情,所以在学习阶段请暂时不要这样做。</P>
            <P>本课结束,请做思考题;监视下列代码中的i和j的值,注意,此题虽然要监视2个变量,但是在代窗口中只要设置1个断点就足够了。<BR>sub 
            test()<BR>for i=2 to 4 step 0.6<BR>&nbsp; for j=-5 to 2 step 
            5.5&nbsp; <BR>&nbsp; next j<BR>next i<BR>end 
            sub<BR></P></FONT><BR></DIV>
            <P align=center><BR><STRONG><A name=trackback></A>引用地址:<A 
            href="http://blog.programfan.com/trackback.asp?id=9251">http://blog.programfan.com/trackback.asp?id=9251</A></STRONG></P>&nbsp;</DIV>
            <DIV>
            <TABLE 
            style="BORDER-RIGHT: #ff9900 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #ff9900 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #ff9900 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #ff9900 1px solid" 
            cellSpacing=0 cellPadding=0 width="95%" align=center border=0>
              <TBODY>
              <TR>
                <TD align=middle bgColor=#ff9900><STRONG><A 
                  name=comment>文章评论</A></STRONG></TD></TR>
              <TR>
                <TD></TD></TR>
              <TR>
                <TD>
                  <FORM name=form1 onsubmit="return check(this);" method=post>
                  <P>&nbsp;</P>
                  <TABLE cellSpacing=0 cellPadding=0 width=380 align=center 
                  border=0>
                    <TBODY>
                    <TR>
                      <TD><SPAN 
                      class=redfont><STRONG>对此文发表评论:</STRONG></SPAN></TD></TR>
                    <TR>
                      <TD>您的昵称:&nbsp;<INPUT maxLength=20 
                        name=username>&nbsp;昵称不填为“匿名”<BR>电子邮件:&nbsp;<INPUT 
                        maxLength=40 name=email><BR>验证码:&nbsp;&nbsp;&nbsp;<INPUT 
                        maxLength=6 size=6 name=getcode><IMG 
                        src="Autocad VBA初级教程 (第三课 程序的调试和保存) -- STEF[CAD&nbsp;CAE&nbsp;C&nbsp;VB&nbsp;MATLAB] -- 编程爱好者BLOG.files/code.bmp"><BR><INPUT 
                        type=hidden value=9251 name=articleid><INPUT type=hidden 
                        value=894 name=blogid>评论内容:(字数请控制在500字以内)<BR><TEXTAREA name=content rows=5 cols=50></TEXTAREA></TD></TR>
                    <TR>
                      <TD>
                        <DIV align=center><INPUT type=submit value=提交 name=Submit></DIV></TD></TR></TBODY></TABLE></FORM></TD></TR></TBODY></TABLE></DIV>
            <DIV><SPAN 
            style="COLOR: #999999"><BR>版权声明:编程爱好者网站为此BLOG服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!</DIV></DIV></SPAN></TD></TR>
        <TR bgColor=#fff7de>
          <TD class=tb_top vAlign=top colSpan=2>
            <DIV align=center>
            <P>&copy; Powered by <A 
            href="http://www.programfan.com/"><STRONG>Programfan.Com 
            </STRONG></A>. All Rights Reserved. </P>
            <P>&nbsp;</P></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -