急!!!高手请帮忙,请问如何将optionbutton控件数组在程序运行的时候,加载到框架中去,或是picture控件中去呀~。

老吴老吴 2004-12-02 01:34:34
高手请帮忙,请问如何将optionbutton控件数组在程序运行的时候,加载到框架中去,或是picture控件中去呀~。

急呀~。。


高手请帮忙呀~。。。
我的QQ:112605936
e-mail:gawood@126.com

...全文
187 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
老吴老吴 2004-12-03
  • 打赏
  • 举报
回复
不好意思~。。。
我第一次来~。。
还不会给分~。。
只给了10分~。
不过还是谢谢你们的帮助~。。。
非常感谢~。。
不过现在又出现了一个问题~。。
问题是现在用了你们两个方法任何一个~。。
可以实现现在的问题~。。
可是当我退出程序的时候都会出现错误~。。
怎么办~?。。

vb6.exe 产生了错误会被windows关闭,您需要重新启动程序。

正在创建错误日志

怎么办~。。。

我再去提这个问题~。。
请两位务必帮忙呀~。。。


老吴老吴 2004-12-02
  • 打赏
  • 举报
回复
谢了楼上的两位~。。
我的问题已经解决了~。。。。
非常感谢~。。。。
………………*^-^*…………………………
myhgyp 2004-12-02
  • 打赏
  • 举报
回复
Dim a(5) As OptionButton '定义五个单选按钮
Private Sub Command2_Click() '动态创建这五个单选按钮
Dim I As Integer
For I = 0 To 5
Set a(I) = Me.Controls.Add("VB.OptionButton", "opt" & I, Me)
a(I).Caption = "这是第" & I & "个"
a(I).Visible = True
a(I).Top = I * 500
Next I
End Sub
Private Sub Command3_Click() '把五个单选按钮放入Frame1框架中
Dim I As Integer
For I = 0 To 5
Set a(I).Container = Frame1
a(I).Top = 500 * (I + 1)
a(I).Left = 200
Next I
End Sub
韧恒 2004-12-02
  • 打赏
  • 举报
回复
Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

SetParent option1(i).hwnd, picture1.hwnd
zhouxiaona 2004-12-02
  • 打赏
  • 举报
回复
我也遇到了同样的问题?。。。
唉~。。。
VB版数字排序拼图小游戏 Option Explicit Dim Label2X As Integer '记录标签控件数组中要移动的标签控件左上角X的位置 Dim Label2Y As Integer '记录标签控件数组中要移动的标签控件左上角Y的位置 '让标签数组中的每个标签控件上显示的数字是随机的,无重复的 Private Sub Init() Randomize Dim a(7) As Integer Dim i As Integer, k As Integer Label1.Caption = "" For i = 0 To 7 a(i) = i Next For i = 0 To 7 k = Int(Rnd * 8) Do While a(k) = -1 'a(k)=-1表示该数组元素对应的数字已经被使用过了 k = Int(Rnd * 8) '重新生成k的值,直到a(k)的值不等于-1 Loop Label2(i).Caption = Trim(Str(a(k))) a(k) = -1 'a(k)的值已经使用了,不能再用,重新赋值为-1与其他的元素值相区别 Next i End Sub Private Sub cb_Click() MsgBox "欢迎观临 陈彬 020901033" End Sub Private Sub Command1_Click() Dim x As Integer, y As Integer Dim z As Integer Init Picture1.Enabled = True '让空白标签Label1出现的位置随机 Randomize '记录下空白标签Label1的位置 x = Label1.Left y = Label1.Top z = Int(Rnd * 8) '将空白标签Label1和标签控件数组任一控件交换位置 Label1.Move Label2(z).Left, Label2(z).Top Label2(z).Move x, y Command1.Enabled = False End Sub Private Sub Command2_Click() End End Sub Private Sub Form_Load() Dim i As Integer Picture1.Enabled = False '在标签中显示游戏说明信息 Label3.Caption = "如左图所示,将数字按0-7顺" & vbCrLf & vbCrLf & "序依次排列,即取得胜利。" '在标签中显示排列规则后的数字顺序 Label1.Caption = 0 For i = 0 To 6 Label2(i).Caption = i + 1 Next End Sub Private Sub Label1_DragDrop(Source As Control, x As Single, y As Single) Dim Label1X As Integer '记录空白控件Label1左上角X的位置 Dim Label1Y As Integer '记录空白控件Label1左上角Y的位置 Dim flag(3) As Boolean '获取空白控件Label1的位置 Label1X = Label1.Left Label1Y = Label1.Top '要移动的控件位于空白控件Label1的正左侧 flag(0) = (Label2X = Label1X - Source.Width) And (Label2Y = Label1Y) '要移动的控件位于空白控件Label1的正右侧 flag(1) = (Label2X = Label1X + Source.Width) And (Label2Y = Label1Y) '要移动的控件位于空白控件Label1的正上方 flag(2) = (Label2X = Label1X) And (Label2Y = Label1Y - Source.Height) '要移动的控件位于空白控件Label1的正下方 flag(3) = (Label2X = Label1X) And (Label2Y = Label1Y + Source.Height) If flag(0) Or flag(1) Or flag(2) Or flag(3) Then Label1.Move Label2X, Label2Y Source.Move Label1X, Label1Y End If Win End Sub Private Sub Label2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single) If Button = vbLeftButton Then '如果按下鼠标左键 '记录下要拖动控件的位置 Label2X = Label2(Index).Left Label2Y = Label2(Index).Top Label2(Index).Drag 1 '启动拖动操作 End If End Sub Private Sub Label2_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single) Label2(Index).Drag 2 '结束拖动操作 End Sub Private Sub Win() Dim winner As Integer Dim i As Integer Dim answer As Integer '对于给定的标签控件数组中的任一标签控件,可以落在符合要求(对应位置应显示对应数字) '的八个位置中的任一位置 '利用循环语句对标签控件数组中的每个标签控件进行检查,如果其落在某一符号要求的位置, '则变量winner的值加1,如果所有标签控件都落在符号要求的位置,则变量winner的值应为8 For i = 0 To 7 If Label2(i).Left = 0 And Label2(i).Top = 0 And _ Label2(i).Caption = 0 Then winner = winner + 1 ElseIf Label2(i).Left = Label2(i).Width And Label2(i).Top = 0 And _ Label2(i).Caption = 1 Then winner = winner + 1 ElseIf Label2(i).Left = 2 * Label2(i).Width And Label2(i).Top = 0 And _ Label2(i).Caption = 2 Then winner = winner + 1 ElseIf Label2(i).Left = 0 And Label2(i).Top = Label2(i).Height And _ Label2(i).Caption = 3 Then winner = winner + 1 ElseIf Label2(i).Left = Label2(i).Width And Label2(i).Top = Label2(i).Height And _ Label2(i).Caption = 4 Then winner = winner + 1 ElseIf Label2(i).Left = 2 * Label2(i).Width And Label2(i).Top = Label2(i).Height And _ Label2(i).Caption = 5 Then winner = winner + 1 ElseIf Label2(i).Left = 0 And Label2(i).Top = 2 * Label2(i).Height And _ Label2(i).Caption = 6 Then winner = winner + 1 ElseIf Label2(i).Left = Label2(i).Width And Label2(i).Top = 2 * Label2(i).Height And _ Label2(i).Caption = 7 Then winner = winner + 1 End If Next i If winner = 8 Then MsgBox " 恭喜您,胜利了!", 0 + 64 + 0, "提示" Picture1.Enabled = False answer = MsgBox("还继续吗?", 4 + 32 + 0, "提示") If answer = vbYes Then Command1.Enabled = True Else End End If End If End Sub
RX Library 2.75 with Delphi 2009 support (by FlexGraphics software) ====================================================================== The Set of Native Delphi Components for Borland Delphi versions 1, 2, 3, 4, 5, 6, 7, 2005, 2006, 2009 and Borland C++ Builder 1, 3, 4, 5, 6, 2006 & 2009. 100% Source Code. Last revision date Oct 12, 1999. PLEASE FOLLOW THE INSTRUCTIONS PROVIDED IN THE INSTALLATION SECTION! TABLE OF CONTENTS ----------------- Latest Changes Overview History License Agreement Installation Demonstration Programs Source Files Using GIF Images Copyright Notes NEW FOR VERSION 2.75 -------------------- Delphi 5.0 & C++Builder 4.0 Compatibility New components: TRxLoginDialog New properties, events: TFormPlacement.RegistryRoot TFormPlacement.Version TFontComboBox.UseFonts TRxDBGrid.OnTopLeftChanged TRxDBLookupCombo.DisplayValues TStrHolder.Macros, TStrHolder.OnExpandMacros RxSpin.TValueType.vtHex New routines, methods, constants: SaveClipboardToStream, LoadClipboardFromStream (clipmon.pas) AppFileName, AppVerInfo (rxverinf.pas) XorString, XorEncode, XorDecode (strutils.pas) BUG FIXES. Overview -------- This version is the result of long unactivity of RX Library authors and some imperfections and bugs of other RX adaptations to Delphi 6. The authors of this version disclaim all warranties as to this software, whether express or implied, including without limitation any implied warranties of merchantability or fitness for a particular purpose. Use under your own responsibility, but comments (even critique) in English (or in Russian) are welcome. RX Library contains a large number of components, objects and routines for Borland Delphi with full source code. This library is compatible with Borland Delphi 1, 2, 3, 4, 5, 6 and Borland C++ Builder 1, 3, 4. This collection includes over 60 native Delphi components. RX Library is a freeware product. Feel free to distribute the library as long as all files are unmodified and kep
Javascript小技巧一箩筐 事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture(); event.srcElement.releaseCapture(); 事件按键 event.keyCode event.shiftKey event.altKey event.ctrlKey 事件返回值 event.returnValue 鼠标位置 event.x event.y 窗体活动元素 document.activeElement 绑定事件 document.captureEvents(Event.KEYDOWN); 访问窗体元素 document.all("txt").focus(); document.all("txt").select(); 窗体命令 document.execCommand 窗体COOKIE document.cookie 菜单事件 document.oncontextmenu 创建元素 document.createElement("SPAN"); 根据鼠标获得元素: document.elementFromPoint(event.x,event.y).tagName=="TD document.elementFromPoint(event.x,event.y).appendChild(ms) 窗体图片 document.images[索引] 窗体事件绑定 document.onmousedown=scrollwindow; 元素 document.窗体.elements[索引] 对象绑定事件 document.all.xxx.detachEvent("onclick",a); 插件数目 navigator.plugins 取变量类型 typeof($js_libpath) == "undefined" 下拉框 下拉框.options[索引] 下拉框.options.length 查找对象 document.getElementsByName("r1"); document.getElementById(id); 定时 timer=setInterval("scrollwindow()",delay); clearInterval(timer); UNCODE编码 escape() ,unescape 父对象 obj.parentElement(dhtml) obj.parentNode(dom) 交换表的行 TableID.moveRow(2,1) 替换CSS document.all.csss.href = "a.css"; 并排显示 display:inline 隐藏焦点 hidefocus=true 根据宽度换行 style="word-break:break-all" 自动刷新 简单邮件 快速转到位置 obj.scrollIntoView(true) 锚 anchors 网页传递参数 location.search(); 可编辑 obj.contenteditable=true 执行菜单命令 obj.execCommand 双字节字符 /[^x00-xff]/ 汉字 /[u4e00-u9fa5]/ 让英文字符串超出表格宽度自动换行 word-wrap: break-word; word-break: break-all; 透明背景 获得style内容 obj.style.cssText HTML标签 document.documentElement.innerHTML 第一个style标签 document.styleSheets[0] style标签里的第一个样式 document.styleSheets[0].rules[0] 防止点击空链接时,页面往往重置到页首端。 word 上一网页源 asp: request.servervariables("HTTP_REFERER") javascript: document.referrer 释放内存 CollectGarbage(); 禁止右键 document.oncontextmenu = function() { return false;} 禁止保存 turn false"> 地址栏图标 favicon.ico 名字最好不变16*16的16色,放虚拟目录根目录下 收藏栏图标 查看源码 button value=查看网页源代码 onclick="window.location = "view-source:"+ "http://www.csdn.net/""> 关闭输入法 自动全选 ENTER键可以让光标移到下一个输入框 文本框的默认值 title换行 obj.title = "123 sdfs " 获得时间所代表的微秒 var n1 = new Date("2004-10-10".replace(/-/g, "/")).getTime() 窗口是否关闭 win.closed checkbox扁平
获取选中内容 document.selection.createRange().duplicate().text 自动完成功能 打开该功能 关闭该功能 窗口最大化 无关闭按钮IE window.open("aa.htm", "meizz", "fullscreen=7"); 统一编码/解码 alert(decodeURIComponent(encodeURIComponent("http://你好.com?as= hehe"))) encodeURIComponent对":"、"/"、";" 和 "?"也编码 表格行指示 //各种尺寸 s += " 网页可见区域宽:"+ document.body.clientWidth; s += " 网页可见区域高:"+ document.body.clientHeight; s += " 网页可见区域高:"+ document.body.offsetWeight +" (包括边线的宽)"; s += " 网页可见区域高:"+ document.body.offsetHeight +" (包括边线的宽)"; s += " 网页正文全文宽:"+ document.body.scrollWidth; s += " 网页正文全文高:"+ document.body.scrollHeight; s += " 网页被卷去的高:"+ document.body.scrollTop; s += " 网页被卷去的左:"+ document.body.scrollLeft; s += " 网页正文部分上:"+ window.screenTop; s += " 网页正文部分左:"+ window.screenLeft; s += " 屏幕分辨率的高:"+ window.screen.height; s += " 屏幕分辨率的宽:"+ window.screen.width; s += " 屏幕可用工作区高度:"+ window.screen.availHeight; s += " 屏幕可用工作区宽度:"+ window.screen.availWidth; //过滤数字 //特殊用途 button value=导入收藏夹 onclick="window.external.ImportExportFavorites(true,"http://localhost");"> button value=导出收藏夹 onclick="window.external.ImportExportFavorites(false,"http://localhost");"> button value=整理收藏夹 onclick="window.external.ShowBrowserUI("OrganizeFavorites", null)"> button value=语言设置 onclick="window.external.ShowBrowserUI("LanguageDialog", null)"> button value=加入收藏夹 onclick="window.external.AddFavorite("http://www.google.com/", "google")"> button value=加入到频道 onclick="window.external.addChannel("http://www.google.com/")"> button value=加入到频道 onclick="window.external.showBrowserUI("PrivacySettings",null)"> //不缓存 //正则匹配匹配中文字符的正则表达式: [u4e00-u9fa5] 匹配双字节字符(包括汉字在内):[^x00-xff] 匹配空行的正则表达式: [s| ]* 匹配HTML标记的正则表达式:/<(.*)>.*|<(.*) />/ 匹配首尾空格的正则表达式:(^s*)|(s*$)(像vbscript那样的trim函数) 匹配Email地址的正则表达式:w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)* 匹配网址URL的正则表达式:http://([w-]+.)+[w-]+(/[w- ./?%&=]*)? 以下是例子: 利用正则表达式限制网页表单里的文本框输入内容: 用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^u4E00-u9FA5]/g,"")" onbeforepaste="clipboardData.setData("text",clipboardData.getData("text").replace(/[^u4E00-u9FA5]/g,""))" 1.用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^uFF00-uFFFF]/g,"")" onbeforepaste="clipboardData.setData("text",clipboardData.getData("text").replace(/[^uFF00-uFFFF]/g,""))" 2.用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^d]/g,"") "onbeforepaste="clipboardData.setData("text",clipboardData.getData("text").replace(/[^d]/g,""))" 3.用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[W]/g,"") "onbeforepaste="clipboardData.setData("text",clipboardData.getData("text").replace(/[^d]/g,""))" //消除图像工具栏 or //无提示关闭 function Close() { var ua=navigator.userAgent var ie=navigator.appName=="Microsoft Internet Explorer"?true:false if(ie) { var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE ")))) if(IEversion< 5.5) { var str = "" str += ""; document.body.insertAdjacentHTML("beforeEnd", str); document.all.noTipClose.Click(); } else { window.opener =null; window.close(); } } else { window.close() } } //取得控件得绝对位置(1) <script language="javascript"> function getoffset(e) { var t=e.offsetTop; var l=e.offsetLeft; while(e=e.offsetParent) { t+=e.offsetTop; l+=e.offsetLeft; } var rec = new Array(1); rec[0] = t; rec[1] = l; return rec } 控件的绝对位置(2) oRect = obj.getBoundingClientRect(); oRect.left oRect. //最小化,最大化,关闭 button value=最小化 onclick=min.Click()> button value=最大化 onclick=max.Click()> button value=关闭 onclick=close.Click()> //光标停在文字最后 <script language="javascript"> function cc() { var e = event.srcElement; var r =e.createTextRange(); r.moveStart("character",e.value.length); r.collapse(true); r.select(); } //页面进入和退出的特效 进入页面 推出页面 这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使 用哪种特效,取值为1-23:   0 矩形缩小   1 矩形扩大   2 圆形缩小   3 圆形扩大   4 下到上刷新   5 上到下刷新   6 左到右刷新   7 右到左刷新   8 竖百叶窗   9 横百叶窗   10 错位横百叶窗   11 错位竖百叶窗   12 点扩散   13 左右到中间刷新   14 中间到左右刷新   15 中间到上下   16 上下到中间   17 右下到左上   18 右上到左下   19 左上到右下   20 左下到右上   21 横条   22 竖条   23 //网页是否被检索   其中属性值有以下一些:   属性值为"all": 文件将被检索,且页上链接可被查询;   属性值为"none": 文件不被检索,而且不查询页上的链接;   属性值为"index": 文件将被检索;   属性值为"follow": 查询页上的链接;   属性值为"noindex": 文件不检索,但可被查询链接;   属性值为"nofollow": //打印分页

page1

page2

//设置打印 button value=页面设置 onclick="factory.printing.PageSetup()"> button value=打印预览 onclick="factory.printing.Preview()"> <script language=javascript> function window.onload() { // -- advanced features factory.printing.SetMarginMeasure(2) // measure margins in inches factory.printing.SetPageRange(false, 1, 3) // need pages from 1 to 3 factory.printing.printer = "HP DeskJet 870C" factory.printing.copies = 2 factory.printing.collate = true factory.printing.paperSize = "A4" factory.printing.paperSource = "Manual feed" // -- basic features factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页" factory.printing.footer = "(自定义页脚)" factory.printing.portrait = false factory.printing.leftMargin = 0.75 factory.printing.topMargin = 1.5 factory.printing.rightMargin = 0.75 factory.printing.bottomMargin = 1.5 } function Print(frame) { factory.printing.Print(true, frame) // print with prompt } button value="打印本页" onclick="factory.printing.Print(false)"> button value="页面设置" onclick="factory.printing.PageSetup()"> button value="打印预览" onclick="factory.printing.Preview()">
具体使用手册,更多信息,点这里 //自带的打印预览 WebBrowser.ExecWB(1,1) 打开 Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口 Web.ExecWB(4,1) 保存网页 Web.ExecWB(6,1) 打印 Web.ExecWB(7,1) 打印预览 Web.ExecWB(8,1) 打印页面设置 Web.ExecWB(10,1) 查看页面属性 Web.ExecWB(15,1) 好像是撤销,有待确认 Web.ExecWB(17,1) 全选 Web.ExecWB(22,1) 刷新 Web.ExecWB(45,1) 关闭窗体无提示
button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)> button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)> button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)>

button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>

//去掉打印时的页眉页脚 <script language="JavaScript"> var HKEY_Root,HKEY_Path,HKEY_Key; HKEY_Root="HKEY_CURRENT_USER"; HKEY_Path="\Software\Microsoft\Internet Explorer\PageSetup\"; //设置网页打印的页眉页脚为空 function PageSetup_Null() { try { var Wsh=new ActiveXObject("WScript.Shell"); HKEY_Key="header"; Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); HKEY_Key="footer"; Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); } catch(e){} } //设置网页打印的页眉页脚为默认值 function PageSetup_Default() { try { var Wsh=new ActiveXObject("WScript.Shell"); HKEY_Key="header"; Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P"); HKEY_Key="footer"; Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d"); } catch(e){} } tup_Null()> tup_Default()> //浏览器验证 function checkBrowser() { this.ver=navigator.appVersion this.dom=document.getElementById?1:0 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0; this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; this.ie4=(document.all && !this.dom)?1:0; this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; this.ns4=(document.layers && !this.dom)?1:0; this.mac=(this.ver.indexOf("Mac") > -1) ?1:0; this.ope=(navigator.userAgent.indexOf("Opera")>-1); this.ie=(this.ie6 || this.ie5 || this.ie4) this.ns=(this.ns4 || this.ns5) this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope) this.nbw=(!this.bw) return this; } //计算内容宽和高 //无模式的提示框 function modelessAlert(Msg) { window.showModelessDialog("javascript:alert(""+escape(Msg)+"");window.close();","","status:no;resizable:no;help:no;dialogHeight:height:30px;dialogHeight:40px;"); } //屏蔽按键 屏蔽鼠标右键、Ctrl+N、Shift+F10、Alt+F4、F11、F5刷新、退格键 <script language="Javascript"> //可编辑SELECT //设置光标位置 function getCaret(textbox) { var control = document.activeElement; textbox.focus(); var rang = document.selection.createRange(); rang.setEndPoint("StartToStart",textbox.createTextRange()) control.focus(); return rang.text.length; } function setCaret(textbox,pos) { try { var r =textbox.createTextRange(); r.moveStart("character",pos); r.collapse(true); r.select(); } catch(e) {} } function selectLength(textbox,start,len) { try { var r =textbox.createTextRange(); r.moveEnd("character",len-(textbox.value.length-start)); r.moveStart("character",start); r.select(); } catch(e) {//alert(e.description)} } function insertAtCaret(textbox,text) { textbox.focus(); document.selection.createRange().text = text; } //页内查找 function findInPage(str) { var txt, i, found,n = 0; if (str == "") { return false; } txt = document.body.createTextRange(); for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit"); } if (found) { txt.moveStart("character", -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } else { if (n > 0) { n = 0; findInPage(str); } else { alert(str + "... 您要找的文字不存在。 试着输入页面中的关键字再次查找!"); } } return false; } //书 http://www.itpub.net/attachment.php?s=&postid=1894598 http://www.wrclub.net/down/listdown.aspx?id=1341//操作EXECL <script language="javascript"> function jStartExcel() { var xls = new ActiveXObject ( "Excel.Application" ); xls.visible = true; var newBook = xls.Workbooks.Add; newBook.Worksheets.Add; newBook.Worksheets(1).Activate; xls.ActiveWorkBook.ActiveSheet.PageSetup.Orientation = 2; xls.ActiveWorkBook.ActiveSheet.PageSetup.PaperSize = 5; newBook.Worksheets(1).Columns("A").columnwidth=50; newBook.Worksheets(1).Columns("A").WrapText = true; newBook.Worksheets(1).Columns("B").columnwidth=50; newBook.Worksheets(1).Columns("B").WrapText = true; newBook.Worksheets(1).Range("A1:B1000").NumberFormat = "0"; newBook.Worksheets(1).Range("A1:B1000").HorizontalAlignment = -4131; newBook.Worksheets(1).Cells(1,1).Interior.ColorIndex="15"; newBook.Worksheets(1).Cells(1,1).value="First Column, First Cell"; newBook.Worksheets(1).Cells(2,1).value="First Column, Second Cell"; newBook.Worksheets(1).Cells(1,2).value="Second Column, First Cell"; newBook.Worksheets(1).Cells(2,2).value="Second Column, Second Cell"; newBook.Worksheets(1).Name="My First WorkSheet"; } tip <script Language="JavaScript"> //***********默认设置定义.********************* tPopWait=50;//停留tWait豪秒后显示提示。 tPopShow=5000;//显示tShow豪秒后关闭提示 showPopStep=20; popOpacity=99; //***************内部变量定义***************** sPop=null; curShow=null; tFadeOut=null; tFadeIn=null; tFadeWaiting=null; document.write(""); document.write("
"); function showPopupText(){ var o=event.srcElement; MouseX=event.x; MouseY=event.y; if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""}; if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""}; if(o.dypop!=sPop) { sPop=o.dypop; clearTimeout(curShow); clearTimeout(tFadeOut); clearTimeout(tFadeIn); clearTimeout(tFadeWaiting); if(sPop==null || sPop=="") { dypopLayer.innerHTML=""; dypopLayer.style.filter="Alpha()"; dypopLayer.filters.Alpha.opacity=0; } else { if(o.dyclass!=null) popStyle=o.dyclass else popStyle="cPopText"; curShow=setTimeout("showIt()",tPopWait); } } } function showIt(){ dypopLayer.className=popStyle; dypopLayer.innerHTML=sPop; popWidth=dypopLayer.clientWidth; popHeight=dypopLayer.clientHeight; if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24 else popLeftAdjust=0; if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24 else popTopAdjust=0; dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust; dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust; dypopLayer.style.filter="Alpha(Opacity=0)"; fadeOut(); } function fadeOut(){ if(dypopLayer.filters.Alpha.opacity0) { dypopLayer.filters.Alpha.opacity-=1; tFadeIn=setTimeout("fadeIn()",1); } } document.onmouseover=showPopupText; turn false; var sel = document.selection; if (sel!=null) { var rng = sel.createRange(); if (rng!=null) rng.pasteHTML("插入文字"); } } //netscapte下操作xml doc = new ActiveXObject("Msxml2.DOMDocument"); doc = new ActiveXObject("Microsoft.XMLDOM") ->> doc = (new DOMParser()).parseFromString(sXML,"text/xml") //判断键值 <script language="javascript"> var ie =navigator.appName=="Microsoft Internet Explorer"?true:false; function keyDown(e) { if(!ie) { var nkey=e.which; var iekey="现在是ns浏览器"; var realkey=String.fromCharCode(e.which); } if(ie) { var iekey=event.keyCode; var nkey="现在是ie浏览器"; var realkey=String.fromCharCode(event.keyCode); if(event.keyCode==32){realkey="" 空格""} if(event.keyCode==13){realkey="" 回车""} if(event.keyCode==27){realkey="" Esc""} if(event.keyCode==16){realkey="" Shift""} if(event.keyCode==17){realkey="" Ctrl""} if(event.keyCode==18){realkey="" Alt""} } alert("ns浏览器中键值:"+nkey+" "+"ie浏览器中键值:"+iekey+" "+"实际键为"+realkey); } document.onkeydown = keyDown; //Javascript Document.

按任意一个键。。。。

//禁止FSO 1.注销组件 regsvr32 /u scrrun.dll 2.修改PROGID HKEY_CLASSES_ROOTScripting.FileSystemObject Scripting.FileSystemObject 3.对于使用object的用户,修改HKEY_CLASSES_ROOTScripting. //省略号
就是比如有一行文字,很长,表格内一行显示不下.
//检测media play版本 //图象按比例 <script language="JavaScript"> //细线SELECT function getComputerName() { var objWMIService = GetObject("Winmgmts:rootcimv2"); for(e = new Enumerator(objWMIService) ; !e.atEnd() ; e.moveNext()) { var getComputer = e.item(); return getComputer.Name; } } //条件编译 <script language=javascript> /*@cc_on @*/ /*@if (@_win32 && @_jscript_version>5) function window.confirm(str) { execScript("n = msgbox(""+ str +"", 257)", "vbscript"); return(n == 1); } @end @*/ //mergeAttributes 复制所有读/写标签属性到指定元素。
This is a sample DIV element.
This is another sample DIV element.
以上内容可以随意转载,转载后注名来源和出处! 原文链接:http://ttyp.cnblogs.com/archive/2004/11/15/63900.aspx //Import function Import() { for( var i=0; i"); else document.write(""); } }; //js枚举 function getComputerName() { var objWMIService = GetObject("Winmgmts:rootcimv2"); for(e = new Enumerator(objWMIService) ; !e.atEnd() ; e.moveNext()) { var getComputer = e.item(); return getComputer.Name; } } //条件编译 <script language=javascript> /*@cc_on @*/ /*@if (@_win32 && @_jscript_version>5) function window.confirm(str) { execScript("n = msgbox(""+ str +"", 257)", "vbscript"); return(n == 1); } @end @*/ //mergeAttributes 复制所有读/写标签属性到指定元素。
This is a sample DIV element.
This is another sample DIV element.
电子书制作:源码爱好者
‘文本朗读.vbpType=ExeReference=*G{00020430-0000-0000-C000-000000000046}#2.0#0#C:WINDOWSSystem32stdole2.tlb#OLE AutomationReference=*G{C866CA3A-32F7-11D2-9602-00C04F8EE628}#5.0#0#C:Program FilesCommon FilesMicrosoft SharedSpeechsapi.dll#Microsoft Speech Object LibraryReference=*G{00020905-0000-0000-C000-000000000046}#8.3#0#C:Program FilesMicrosoft OfficeOFFICE11MSWORD.OLB#Microsoft Word 11.0 Object LibraryObject={3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0; richtx32.ocxObject={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; COMDLG32.OCXForm=文本朗读.frmForm=frmAbout.frmModule=mDeclares; MoudlesmDeclares.basModule=MSubclass; Moudlessubclass.basModule=MTimer; Moudles imer.basClass=cMemDC; ClassMoudlescMemDC.clsClass=cMenuBar; ClassMoudlescMenuBar.clsClass=cNCCalcSize; ClassMoudlescNCCalcSize.clsClass=cNeoCaption; ClassMoudlescNeoCaption.clsClass=cToolbarMenu; ClassMoudlescToolbarMenu.clsClass=INCAreaModifier; ClassMoudlesINCAreaModifier.clsClass=ISubclass; ClassMoudlesisubclass.clsClass=GSubclass; ClassMoudlessubclass.clsClass=CTimer; ClassMoudles imer.clsModule=Module1; Module1.basObject={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0; COMCTL32.OCXIconForm="Form1"Startup="Form1"HelpFile=""Title="文本朗读"ExeName32="文本朗读.exe"Command32=""Name="工程1"HelpContextID="0"CompatibleMode="0"MajorVer=1MinorVer=1RevisionVer=22AutoIncrementVer=1ServerSupportFiles=0VersionCompanyName="安阳市监狱"CompilationType=0OptimizationType=0FavorPentiumPro(tm)=0CodeViewDebugInfo=0NoAliasing=0BoundsCheck=0OverflowCheck=0FlPointCheck=0FDIVCheck=0UnroundedFP=0StartMode=0Unattended=0Retained=0ThreadPerObject=0MaxNumberOfThreads=1DebugStartupOption=0[MS Transaction Server]AutoRefresh=1‘文本朗读.frmVERSION 5.00Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "richtx32.ocx"Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"Begin VB.Form Form1 AutoRedraw = -1 ‘True Caption = "文本播放器 1.1版" ClientHeight = 6255 ClientLeft = 165 ClientTop = 555 ClientWidth = 9855 Icon = "文本朗读.frx":0000 LinkTopic = "Form1" ScaleHeight = 6255 ScaleWidth = 9855 StartUpPosition = 2 ‘屏幕中心 Begin VB.HScrollBar HScroll2 Height = 255 Left = 1080 Max = 100 TabIndex = 14 Top = 5880 Value = 50 Width = 1815 End Begin VB.PictureBox PicCaption Height = 495 Left = 240 Picture = "文本朗读.frx":08CA ScaleHeight = 435 ScaleWidth = 8715 TabIndex = 11 Top = 3960 Visible = 0 ‘False Width = 8775 Begin VB.PictureBox PicBorder Height = 135 Left = 960 Picture = "文本朗读.frx":1710C ScaleHeight = 75 ScaleWidth = 915 TabIndex = 12 Top = 240 Visible = 0 ‘False Width = 975 End End Begin VB.CommandButton Command6 Caption = "继续朗读" Height = 390 Left = 150 TabIndex = 10 Top = 3480 Width = 2760 End Begin VB.CommandButton Command5 Caption = "暂停朗读" Height = 390 Left = 150 TabIndex = 9 Top = 3000 Width = 2760 End Begin VB.HScrollBar HScroll1 Height = 255 Left = 1080 Max = 100 TabIndex = 8 Top = 5400 Value = 100 Width = 1815 End Begin MSComDlg.CommonDialog CDg1 Left = 6840 Top = 4560 _ExtentX = 847 _ExtentY = 847 _Version = 393216 Filter = "文本文件(*.txt)|*.txt|所有文件|*.*" FilterIndex = 2 End Begin VB.OptionButton Option2 Caption = "朗读选定" Height = 315 Left = 1800 TabIndex = 6 Top = 4920 Width = 1230 End Begin VB.OptionButton Option1 Caption = "朗读全文" Height = 315 Left = 120 TabIndex = 5 Top = 4920 Width = 1230 End Begin VB.CommandButton Command4 Caption = "退出程序" Height = 390 Left = 150 TabIndex = 4 Top = 4440 Width = 2760 End Begin VB.CommandButton Command3 Caption = "结束朗读" Height = 390 Left = 150 TabIndex = 3 Top = 3960 Width = 2760 End Begin VB.CommandButton Command2 Caption = "开始朗读" Height = 390 Left = 150 TabIndex = 2 Top = 2520 Width = 2760 End Begin VB.CommandButton Command1 Caption = "打开文件" Height = 390 Left = 150 TabIndex = 1 Top = 2040 Width = 2760 End Begin RichTextLib.RichTextBox RTf1 Height = 6105 Left = 3120 TabIndex = 0 Top = 30 Width = 6615 _ExtentX = 11668 _ExtentY = 10769 _Version = 393217 BackColor = 15138775 HideSelection = 0 ‘False ScrollBars = 2 AutoVerbMenu = -1 ‘True TextRTF = $"文本朗读.frx":17996 End Begin VB.Label Label1 AutoSize = -1 ‘True Caption = "语速调节:" Height = 180 Index = 1 Left = 120 TabIndex = 13 Top = 5880 Width = 900 End Begin VB.Label Label1 AutoSize = -1 ‘True Caption = "音量调节:" Height = 180 Index = 0 Left = 120 TabIndex = 7 Top = 5400 Width = 900 End Begin VB.Image Image1 Height = 1935 Left = -15 Picture = "文本朗读.frx":17A33 Stretch = -1 ‘True Top = 30 Width = 3075 End Begin VB.Menu FILEMNU Caption = "文件(&F)" Begin VB.Menu OPENMNU Caption = "打开(&O)" End Begin VB.Menu LDMNU Caption = "朗读(&L)" End Begin VB.Menu FG Caption = "-" End Begin VB.Menu EXTMNU Caption = "退出(&X)" End End Begin VB.Menu HILMNU Caption = "帮助(&H)" Begin VB.Menu aboutmnu Caption = "关于…" End EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseDim ld As New SpeechLib.SpVoiceDim qorx As BooleanDim wb As StringPrivate m_cN As cNeoCaption‘这是我又一次对文本播放器进行修订,‘增加了打开word、rtf文本、音量调节功能‘但是如何保存文声音文件还没做到,对TTS的安装等还没搞清楚,‘今后还需进一步努力加以改进。yxf 2004年5月30日‘------------------------------------------------------------------‘增加语速控制功能 2004年6月28日Private Sub aboutmnu_Click()frmAbout.Show 1End SubPrivate Sub Command1_Click()On Error Resume NextRTf1.Text = ""Dim str As StringDim lstr$CDg1.ShowOpenIf CDg1.FileName <> "" ThenIf LCase(right(CDg1.FileName, 3)) = "rtf" ThenRTf1.LoadFile CDg1.FileName, 0ElseIf LCase(right(CDg1.FileName, 3)) = "doc" ThenForm1.Caption = "文本播放器1.1版--正在打开文件……"Dim myword As New Word.Applicationmyword.Documents.Open FileName:=CDg1.FileName myword.Selection.WholeStoryRTf1.Text = myword.Selectionmyword.Quit Set myword = NothingElseIf LCase(right(CDg1.FileName, 3)) = "txt" ThenForm1.Caption = "文本播放器1.1版--正在打开文件……"RTf1.LoadFile CDg1.FileName, rtfText‘opentxt CDg1.FileName, str, lstr‘RTf1 = lstrElse If MsgBox("文件无法识别,按文本格式打开?", vbYesNo, "提示") = 6 ThenForm1.Caption = "文本播放器1.1版--正在打开文件……"opentxt CDg1.FileName, str, lstrRTf1 = lstr Else Exit Sub End IfEnd IfEnd IfMe.Caption = "文本播放器1.1版--" + CDg1.FileNameEnd SubPrivate Sub Command2_Click()On Error Resume NextIf qorx Thenwb = RTf1.TextElsewb = RTf1.SelTextEnd IfSet ld = New SpeechLib.SpVoiceld.Volume = HScroll1ld.Rate = HScroll2 / 10ld.Speak wb, 1End SubPrivate Sub Command3_Click()ld.Speak "", 2Set ld = NothingEnd SubPrivate Sub Command4_Click()ld.Speak "", 2Set ld = NothingEndEnd SubPrivate Sub Command5_Click()On Error Resume Nextld.PauseEnd SubPrivate Sub Command6_Click()On Error Resume Nextld.ResumeEnd SubPrivate Sub EXTMNU_Click()Command4_ClickEnd SubPrivate Sub Form_Resize()If Form1.Width > 3300 And Me.Height > 5000 ThenForm1.RTf1.Width = Me.Width - 3300RTf1.Height = Me.Height - 1000ElseRTf1.Width = 5895End IfEnd SubPrivate Sub Skin(f As Form, cN As cNeoCaption) cN.ActiveCaptionColor = &HFFFFFF cN.InActiveCaptionColor = &HC0C0C0 cN.ActiveMenuColor = &H0& cN.ActiveMenuColorOver = &H0 cN.InActiveMenuColor = &H0& cN.MenuBackgroundColor = RGB(207, 203, 207) cN.CaptionFont.Name = "宋体" cN.CaptionFont.Size = 9 cN.MenuFont.Name = "宋体" cN.MenuFont.Size = 9 cN.Attach f, f.PicCaption.Picture, f.PicBorder.Picture, 19, 20, 90, 140, 240, 400 f.BackColor = RGB(207, 203, 207)End SubPrivate Sub Form_Load()‘Dim X0 As Long‘Dim Y0 As Long‘让窗体居中‘X0 = Screen.Width‘Y0 = Screen.Height‘X0 = (X0 - Me.Width) / 2‘Y0 = (Y0 - Me.Height) / 2‘Me.Move X0, Y0‘ Set m_cN = New cNeoCaption ‘ Skin Me, m_cNqorx = TrueRTf1.Text = " 文本播放器1.1版" + vbCrLf + " 河南省安阳市育才路" + vbCrLf + " 2004年5月8日"Option1.Value = TrueEnd SubPrivate Sub Form_Unload(Cancel As Integer)Command4.Value = TrueEnd SubPrivate Sub HScroll1_Change()On Error Resume Nextld.Volume = HScroll1End SubPrivate Sub HScroll2_Change()On Error Resume Nextld.Rate = HScroll2 / 10End SubPrivate Sub LDMNU_Click()Command2_ClickEnd SubPrivate Sub OPENMNU_Click()Command1_ClickEnd SubPrivate Sub Option2_Click()qorx = FalseEnd SubPrivate Sub Option1_Click()qorx = TrueEnd SubVERSION 5.00Begin VB.Form frmAbout BorderStyle = 3 ‘Fixed Dialog Caption = "关于 文本朗读器" ClientHeight = 3555 ClientLeft = 2340 ClientTop = 1935 ClientWidth = 5730 ClipControls = 0 ‘False Icon = "frmAbout.frx":0000 LinkTopic = "Form2" MaxButton = 0 ‘False MinButton = 0 ‘False ScaleHeight = 2453.724 ScaleMode = 0 ‘User ScaleWidth = 5380.766 ShowInTaskbar = 0 ‘False Begin VB.CommandButton cmdOK Cancel = -1 ‘True Caption = "确定" Default = -1 ‘True Height = 345 Left = 4125 TabIndex = 0 Top = 2625 Width = 1500 End Begin VB.CommandButton cmdSysInfo Caption = "系统信息(&S)..." Height = 345 Left = 4140 TabIndex = 1 Top = 3075 Width = 1485 End Begin VB.Label Label1 Caption = "作者:河南省安阳市监狱 yxf" Height = 255 Left = 240 TabIndex = 6 Top = 3240 Width = 3735 End Begin VB.Image Image1 BorderStyle = 1 ‘Fixed Single Height = 675 Left = 120 Picture = "frmAbout.frx":08CA Stretch = -1 ‘True Top = 240 Width = 720 End Begin VB.Line Line1 BorderColor = &H00808080& BorderStyle = 6 ‘Inside Solid Index = 1 X1 = 84.515 X2 = 5309.398 Y1 = 1687.583 Y2 = 1687.583 End Begin VB.Label lblDescription Caption = $"frmAbout.frx":175602 ForeColor = &H00000000& Height = 1170 Left = 1080 TabIndex = 2 Top = 1125 Width = 3765 End Begin VB.Label lblTitle Caption = "文本朗读器" BeginProperty Font Name = "隶书" Size = 21.75 Charset = 134 Weight = 400 Underline = -1 ‘True Italic = -1 ‘True Strikethrough = 0 ‘False EndProperty ForeColor = &H000000FF& Height = 600 Left = 1080 TabIndex = 4 Top = 120 Width = 3885 End Begin VB.Line Line1 BorderColor = &H00FFFFFF& BorderWidth = 2 Index = 0 X1 = 98.6 X2 = 5309.398 Y1 = 1697.936 Y2 = 1697.936 End Begin VB.Label lblVersion Caption = "版本:1.1" Height = 225 Left = 1050 TabIndex = 5 Top = 780 Width = 3885 End Begin VB.Label lblDisclaimer Caption = "警告:本软件可以自由使用,但因对其使用而 带来的任何不良后果概不负责!" ForeColor = &H00000000& Height = 420 Left = 255 TabIndex = 3 Top = 2625 Width = 3630 EndEndAttribute VB_Name = "frmAbout"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption Explicit‘ 注册表关键字安全选项...Const READ_CONTROL = &H20000Const KEY_QUERY_VALUE = &H1Const KEY_SET_VALUE = &H2Const KEY_CREATE_SUB_KEY = &H4Const KEY_ENUMERATE_SUB_KEYS = &H8Const KEY_NOTIFY = &H10Const KEY_CREATE_LINK = &H20Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _ KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _ KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL ‘ 注册表关键字 ROOT 类型...Const HKEY_LOCAL_MACHINE = &H80000002Const ERROR_SUCCESS = 0Const REG_SZ = 1 ‘ 独立的空的终结字符串Const REG_DWORD = 4 ‘ 32位数字Const gREGKEYSYSINFOLOC = "SOFTWAREMicrosoftShared Tools Location"Const gREGVALSYSINFOLOC = "MSINFO"Const gREGKEYSYSINFO = "SOFTWAREMicrosoftShared ToolsMSINFO"Const gREGVALSYSINFO = "PATH"Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As LongPrivate Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As LongPrivate Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As LongPrivate Sub cmdSysInfo_Click() Call StartSysInfoEnd SubPrivate Sub cmdOK_Click() Unload MeEnd SubPrivate Sub Form_Load()Dim X0 As LongDim Y0 As Long‘让窗体居中X0 = Screen.WidthY0 = Screen.HeightX0 = (X0 - Me.Width) / 2Y0 = (Y0 - Me.Height) / 2Me.Move X0, Y0End SubPublic Sub StartSysInfo() On Error GoTo SysInfoErr Dim rc As Long Dim SysInfoPath As String ‘ 试图从注册表中获得系统信息程序的路径及名称... If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then ‘ 试图仅从注册表中获得系统信息程序的路径... ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then ‘ 已知32位文件版本的有效位置 If (Dir(SysInfoPath & "MSINFO32.EXE") <> "") Then SysInfoPath = SysInfoPath & "MSINFO32.EXE" ‘ 错误 - 文件不能被找到... Else GoTo SysInfoErr End If ‘ 错误 - 注册表相应条目不能被找到... Else GoTo SysInfoErr End If Call Shell(SysInfoPath, vbNormalFocus) Exit SubSysInfoErr: MsgBox "此时系统信息不可用", vbOKOnlyEnd SubPublic Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean Dim i As Long ‘ 循环计数器 Dim rc As Long ‘ 返回代码 Dim hKey As Long ‘ 打开的注册表关键字句柄 Dim hDepth As Long ‘ Dim KeyValType As Long ‘ 注册表关键字数据类型 Dim tmpVal As String ‘ 注册表关键字值的临时存储器 Dim KeyValSize As Long ‘ 注册表关键自变量的尺寸 ‘------------------------------------------------------------ ‘ 打开 {HKEY_LOCAL_MACHINE...} 下的 RegKey ‘------------------------------------------------------------ rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ‘ 打开注册表关键字 If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ‘ 处理错误... tmpVal = String$(1024, 0) ‘ 分配变量空间 KeyValSize = 1024 ‘ 标记变量尺寸 ‘------------------------------------------------------------ ‘ 检索注册表关键字的值... ‘------------------------------------------------------------ rc = RegQueryValueEx(hKey, SubKeyRef, 0, _ KeyValType, tmpVal, KeyValSize) ‘ 获得/创建关键字值 If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ‘ 处理错误 If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ‘ Win95 外接程序空终结字符串... tmpVal = Left(tmpVal, KeyValSize - 1) ‘ Null 被找到,从字符串中分离出来 Else ‘ WinNT 没有空终结字符串... tmpVal = Left(tmpVal, KeyValSize) ‘ Null 没有被找到, 分离字符串 End If ‘------------------------------------------------------------ ‘ 决定转换的关键字的值类型... ‘------------------------------------------------------------ Select Case KeyValType ‘ 搜索数据类型... Case REG_SZ ‘ 字符串注册关键字数据类型 KeyVal = tmpVal ‘ 复制字符串的值 Case REG_DWORD ‘ 四字节的注册表关键字数据类型 For i = Len(tmpVal) To 1 Step -1 ‘ 将每位进行转换 KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ‘ 生成值字符。 By Char。 Next KeyVal = Format$("&h" + KeyVal) ‘ 转换四字节的字符为字符串 End Select GetKeyValue = True ‘ 返回成功 rc = RegCloseKey(hKey) ‘ 关闭注册表关键字 Exit Function ‘ 退出 GetKeyError: ‘ 错误发生后将其清除... KeyVal = "" ‘ 设置返回值到空字符串 GetKeyValue = False ‘ 返回失败 rc = RegCloseKey(hKey) ‘ 关闭注册表关键字End Function

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧