使用 addin 程式可以加快我們的開發速度
以下幾個例子,是我個人在平常工作中常用到
1.統一改變窗體的控制項字型及字型大小
set objcom = vbinstance.selectedvbcomponent
if (objcom.type <> vbext_ct_vbform) and _
(objcom.type <> vbext_ct_usercontrol) and _
(objcom.type <> vbext_ct_docobject) and _
(objcom.type <> vbext_ct_proppage) then
exit sub
end if
for each objctrl in objcom.designer.vbcontrols
objctrl.controlobject.fontname = me.cbofont.text
objctrl.controlobject.fontsize = val(me.cbofontsize.text)
objctrl.controlobject.font.name = me.cbofont.text
objctrl.controlobject.font.size = val(me.cbofontsize.text)
objctrl.properties("fontname").value = me.cbofont.text
objctrl.properties("fontsize").value = val(me.cbofontsize.text)
next
2. 根據資料庫設定,動態生成選單
private sub createmenu(byval prsdata as adodb.recordset, byval pobjcom as vbcomponent, pobjparent as vbcontrol, byval pstrparentid as string)
dim rs as adodb.recordset
dim objctrls as vbcontrols
dim objctrl as vbcontrol
dim strmenuid as string
dim strcap as string
dim i as integer
dim intidx as integer
on error goto error_label
intidx = 0
set rs = prsdata.clone
rs.filter = "parentid='" & pstrparentid & "'"
if rs.recordcount > 0 then
' msgbox rs.recordcount
rs.sort = "functionindex"
for i = 1 to rs.recordcount
strmenuid = trim(rs.collect("menuid") & "")
strcap = trim(rs.collect("menuname") & "")
if pobjparent is nothing then
set objctrls = pobjcom.designer.vbcontrols
set objctrl = objctrls.add("vb.menu")
else
set objctrl = pobjparent.containedvbcontrols.add("vb.menu", pobjparent)
end if
objctrl.properties!index = val(rs.collect("functionindex") & "")
objctrl.properties!name = rs.collect("functionname") & ""
if strcomp(strcap, "-", vbtextcompare) <> 0 then
if len(trim(rs.collect("shortcut") & "")) > 0 then
strcap = strcap & "(" & rs.collect("shortcut") & "" & ")"
else
intidx = intidx + 1
if intidx > 9 then
strcap = "&" & chr(64 + intidx - 9) & ". " & strcap
else
strcap = "&" & cstr(intidx) & ". " & strcap
end if
end if
objctrl.properties!caption = strcap
else
objctrl.properties!caption = strcap
end if
if haschildmenu(prsdata, strmenuid) then
call createmenu(prsdata, pobjcom, objctrl, strmenuid)
end if
rs.movenext
next i
end if
error_label:
if err.number <> 0 then
' msgbox "createmenu->" & err.description
err.clear
resume next
end if
end sub
如何在VB6中匯出EXCEL FOXPRO格式的表
這麼簡單的方法。不知道太可惜了 select into excel 8.0 database 匯出目錄 匯出表名 from 表 select into foxpro 2.6 database 匯出目錄 匯出表名 from 表 select into foxpro 2.5 database 同上 匯出...
如何利用es6去重
以下是三種方法從陣列裡去重,並且返回唯一的值。我最喜歡的方式是使用set,因為它是最短最簡單的。const array 5,2,4,5,3 console.log new set array console.log array.filter item,index array.indexof item...
VB中如何宣告及使用多維陣列,多層陣列及動態陣列
宣告固定大小的陣列 有三種方法宣告固定大小的陣列,用哪一種方法取決於陣列應有的有效範圍 建立公用陣列,在模組的宣告段用 public 語句宣告陣列。建立模組級陣列,在模組的宣告段用 private 語句宣告陣列。建立區域性陣列,在過程中用 private 語句宣告陣列。設定上下界 宣告陣列時,在陣列...