欢迎来到天天文库
浏览记录
ID:37713694
大小:21.56 KB
页数:14页
时间:2019-05-29
《VBA随机数源码汇总》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、(defunrnd(rMinrMax)(vla-eval(vlax-get-acad-object)"ThisDrawing.setVariable"USERR5",CDbl((Rnd))")(+rMin(*(getvar"userr5")(-rMaxrMin))));;;(setqArgLst’("Doyouwanttocontinue?"50;;;"MsgBoxDemonstration""DEMO.HLP"1000));;;用法:(MsgBoxArglst)(defunMsgbox(ArgLst/MsgStyleTitleHelpfnCtxt)(mapcar’se
2、t(list’Msg’Style’Title’Helpfn’Ctxt)ArgLst)(vla-eval(vlax-get-acad-object)(strcat"ThisDrawing.setVariable"USERI5",CInt((MsgBox(""Msg"""(ifStyle(strcat","(itoaStyle))"")(ifTitle(strcat",""Title""")"")(ifHelpfn(strcat",""Helpfn""")"")(ifCtxt(strcat","(itoaCtxt))"")")))"))(getvar"useri
3、5"))(defunStrConv(Strconv)(vla-eval(vlax-get-acad-object)(strcat"ThisDrawing.setVariable"USERS5",CStr((StrConv(""Str"","(itoaConv)")))"))(getvar"users5"));
4、(X-vbfuntypvbfun)=运行简单的vb函数-v1.0b----------梦断江南.2004.9参数:typ=函数返回值的vb类型.vbfun=简单的vb函数.返回:设置于"USERR5"变量中的值.实例:(x-vbfun’variant’(rnd
5、));;出错.显示设置系统变量出错.!!(x-vbfun’double’(rnd));;->0.533424:取得随机数.ok(x-vbfun’integer’(msgbox("hello,x-vbfun",3,"test")));;->6.0:显示信息框,参数详vb函数参考.ok.(x-vbfun’single’(msgbox("test1",3)));;出错.显示设置系统变量出错.!!要点:typ必须于vbfun返回值类型相一致!!!参考:http://www.xdcad.net/forum/showthread.php?s=&threadid=259492
6、;(DEF
7、UNX-vbfun(typvbfun/typlst)(setqtyplst’(("BOOLEAN"."CBOOL")("BYTE"."CBYTE")("CURRENCY"."CCUR")("DOUBLE"."CDBL")("DECIMAL"."CDEC")("INTEGER"."CINT")("LONG"."CLNG")("SINGLE"."CSNG")("STRING"."CSTR")("VARIANT"."CVAR")))(vla-eval(vlax-get-acad-object)(strcat"thisdrawing.setvariable"USERR5","(
8、cdr(assoc(strcase(vl-symbol-nametyp))typlst))"("(vl-prin1-to-stringvbfun)")"))(getvar"USERR5"))提醒一点,好像都没有想过把User系列变量还原,?好像用Users1~5要好些吧?Msgbox用下面的代替,也可以(vlax-invoke-method(vlax-create-object"WScript.Shell")"Popup""why"7"AnswerThisQuestion:"1)实际上WScript.Shell的功能也很强大,:)发现一个办法,可以不用传递系统变量了(set
9、qa(vlax-create-Object"ScriptControl"))(vlax-put-propertya"language""vbs")(vla-evala"Rnd()")前面的(setqa(vla-GetInterfaceObject(vlax-get-acad-object)"ScriptControl"))(vlax-put-propertya"language""vbs")只运行一次你应该只运行(vla-evala"Rnd()")VB的随机数是“伪随机数”,:)VB的随机数,也是通过一种算法进行运
此文档下载收益归作者所有