广州明生堂生物科技有限公司


用vbs实现选择颜色

网络编程 用vbs实现选择颜色 06-22
如果不用组件的话,代码如下:

set ie = createobject("internetexplorer.application")
ie.navigate "about:blank"
do until ie.readystate = 4 : wscript.sleep 25 : loop
set doc = ie.document
set body = doc.body
set win = doc.parentwindow
body.innerhtml = "<OBJECT id=dlg CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b'></OBJECT>"
body.innertext = doc.getElementById("dlg").choosecolordlg
win.clipboarddata.setdata "text", body.innertext
ie.quit

如果用组件的话,代码如下:

flag = 1+2
initialColor = &hff32ea
color = OpenColor(initialColor, flag)
MsgBox "Selected color: " & hex(color)
function OpenColor(initColor, flags)
set comdlg = CreateObject("MSComDlg.CommonDialog")
comdlg.Color = initColor
comdlg.Flags = flags
comdlg.ShowColor
OpenColor = comdlg.Color
end function

组件相关文件下载http://xiazai.gimoo.net/jbtools/vb6controls.rar

vbs选择文件夹效果代码
不用组件的话有两种办法:setobjFile=CreateObject("SAFRCFileDlg.FileOpen")SetobjShell=CreateObject("Shell.Application")本blog里都有示例。如果调用vb组件,可以是:flag=&h200whi

vbs的sort排序
FunctionfSortArray(aSortThisArray)DimoArrayList,iElementSetoArrayList=CreateObject("System.Collections.ArrayList")ForiElement=0ToUBound(aSortThisArray)oArrayList.AddaSortThisArray(iElement)NextoArrayL

adodb.stream读文件到数组的代码
Functionfilenum(filename,i)Dimst,sSetst=CreateObject("ADODB.Stream")st.Type=2'流类型为文本st.Mode=3'模式为读写st.Openst.LineSeparator=13st.LoadFromFilefilenameDoWhileNotSt.EOSs=Split(st.rea


编辑:广州明生堂生物科技有限公司

标签:组件,代码,文件,都有,数组