blogjava-凯发k8网页登录
blogjava-凯发k8网页登录http://www.blogjava.net/hwpok/category/49633.htmldebug - 天道酬勤zh-cntue, 08 jul 2014 09:37:12 gmttue, 08 jul 2014 09:37:12 gmt60- excel2pdmhttp://www.blogjava.net/hwpok/archive/2014/07/06/415501.html惠万鹏惠万鹏sun, 06 jul 2014 13:06:00 gmthttp://www.blogjava.net/hwpok/archive/2014/07/06/415501.htmlhttp://www.blogjava.net/hwpok/comments/415501.htmlhttp://www.blogjava.net/hwpok/archive/2014/07/06/415501.html#feedback0http://www.blogjava.net/hwpok/comments/commentrss/415501.htmlhttp://www.blogjava.net/hwpok/services/trackbacks/415501.html
'******************************************************************************
'* file: excel2pdm.txt
'* title: pdm export to excel
'* purpose: to export the tables and columns to excel
'* model: physical data model
'* objects: table, column, view
'* author: ziyan
'* created: 2012-05-03
'*modifier: hui wanpeng 2014/07/04
'* version: 1.0
'******************************************************************************
option explicit
dim md1 'the current model
set md1=activemodel
if(md1 is nothing) then
msgbox "there is no active model"
end if
dim haveexcel
dim rq
rq = vbyes 'msgbox("is excel installed on your machine?",vbyesno vbinformation,"confirmation")
if rq=vbyes then
haveexcel=true
'open&create excel document
dim x1
set x1=createobject("excel.application")
x1.workbooks.open "e:/tmp/b超检查表.xls"
x1.workbooks(1).worksheets("sheet1").activate
else
haveexcel=false
end if
process x1, md1
sub process(x1,md1)
dim rwindex
dim tablename
dim colname
dim table
dim col
dim count
dim dtype
dim nnull
'on error resume next
for rwindex =1 to 500 step 1
with x1.workbooks(1).worksheets("sheet1")
if .cells(rwindex,1).value="" then
exit for
end if
if .cells(rwindex,3).value="" then
set table=md1.tables.createnew
table.name=.cells(rwindex,2).value
table.code=ucase(.cells(rwindex,1).value)
table.comment=.cells(rwindex,2).value
count=count1
else
colname=.cells(rwindex,1).value
set col=table.columns.createnew
'msgbox.cells(rwindex,1).value
'msgbox colname,vbok vbinformation,"列"
col.code=trim(ucase(.cells(rwindex,1).value))
col.name=trim(ucase( .cells(rwindex,1).value))
col.comment=trim(.cells(rwindex,2).value)
dtype=trim(ucase(.cells(rwindex,3).value))
'msgbox left(dtype, 5)
if left(dtype, 5)="char(" then
dtype=replace(dtype,"char","varchar2")
elseif left(dtype, 5)="cahr(" then
dtype=replace(dtype,"cahr","varchar2")
end if
col.datatype=dtype
nnull=trim(ucase(.cells(rwindex,4).value))
if nnull="not null" then
col.mandatory="true"
end if
end if
end with
next
msgbox "生成数据表结构共计 " cstr(count), vbokvbinformation, "表"
x1.workbooks.close
exit sub
end sub
]]> - vb 托盘http://www.blogjava.net/hwpok/archive/2013/08/01/402247.html惠万鹏惠万鹏thu, 01 aug 2013 03:21:00 gmthttp://www.blogjava.net/hwpok/archive/2013/08/01/402247.htmlhttp://www.blogjava.net/hwpok/comments/402247.htmlhttp://www.blogjava.net/hwpok/archive/2013/08/01/402247.html#feedback0http://www.blogjava.net/hwpok/comments/commentrss/402247.htmlhttp://www.blogjava.net/hwpok/services/trackbacks/402247.htmloption explicit
public const max_tooltip as integer = 64
public const nif_icon = &h2
public const nif_message = &h1
public const nif_tip = &h4
public const nim_add = &h0
public const nim_modify = &h1
public const nim_delete = &h2
public const wm_mousemove = &h200
public const wm_lbuttondown = &h201
public const wm_lbuttonup = &h202
public const wm_lbuttondblclk = &h203
public const wm_rbuttondown = &h204
public const wm_rbuttonup = &h205
public const wm_rbuttondblclk = &h206
public const sw_restore = 9
public const sw_hide = 0
public nficondata as notifyicondata
public type notifyicondata
cbsize as long
hwnd as long
uid as long
uflags as long
ucallbackmessage as long
hicon as long
sztip as string * max_tooltip
end type
public declare function showwindow lib "user32" (byval hwnd as long, byval ncmdshow as long) as long
public declare function shell_notifyicon lib "shell32.dll" alias "shell_notifyicona" (byval dwmessage as long, lpdata as notifyicondata) as long
private sub form_load()
if app.previnstance then
end ' 退出新运行的程序
end if
me.caption = "我的第一个程序"
'以下把程序放入system tray====================================system tray begin
with nficondata
.hwnd = me.hwnd
.uid = me.icon
.uflags = nif_icon or nif_message or nif_tip
.ucallbackmessage = wm_mousemove
.hicon = me.icon.handle
'定义鼠标移动到托盘上时显示的tip
.sztip = app.title "(版本 " & app.major & "." & app.minor & "." & app.revision & ")" & vbnullchar
.cbsize = len(nficondata)
end with
call shell_notifyicon(nim_add, nficondata)
'=============================================================system tray end
me.show
end sub
private sub form_mousemove(button as integer, shift as integer, x as single, y as single)
dim lmsg as single
lmsg = x / screen.twipsperpixelx
select case lmsg
case wm_lbuttonup
'msgbox "请用鼠标右键点击图标!", vbinformation, "实时播音专家"
'单击左键,显示窗体
timer1.enabled = false
call showwindow(me.hwnd, sw_restore)
'下面两句的目的是把窗口显示在窗口最顶层
me.show
me.setfocus
'' case wm_rbuttonup
'' popupmenu menutray '如果是在系统tray图标上点右键,则弹出菜单menutray
'' case wm_mousemove
'' case wm_lbuttondown
'' case wm_lbuttondblclk
'' case wm_rbuttondown
'' case wm_rbuttondblclk
'' case else
end select
end sub
private sub form_queryunload(cancel as integer, unloadmode as integer)
call shell_notifyicon(nim_delete, nficondata)
end sub
private sub form_resize()
if me.windowstate = 1 then
me.hide
end if
end sub
private sub leftbtn_click()
static b1 as boolean '定义一个布尔型变量用于开关作用
b1 = not b1
timer1.enabled = b1 '用timer1来控制图标的闪烁
if not b1 then
leftbtn.caption = "开始"
else
leftbtn.caption = "停止"
end if
end sub
private sub rightbtn_click()
infolabel.caption = "右边按钮"
end sub
private sub timer1_timer()
static b2 as boolean ' 定义一个布尔型变量用于开关作用,当为true时托盘图标为picture2图片,为false时为picture1的图片
b2 = not b2
if b2 then
nficondata.hicon = image1.picture '托盘图标为picture2的图片
infolabel.caption = "b"
else
nficondata.hicon = image2.picture '托盘图标为picture1的图片
infolabel.caption = "a"
end if
call shell_notifyicon(nim_modify, nficondata) '修改托盘图标
end sub
]]> - vba 自定义函数http://www.blogjava.net/hwpok/archive/2011/09/17/358874.html惠万鹏惠万鹏sat, 17 sep 2011 10:25:00 gmthttp://www.blogjava.net/hwpok/archive/2011/09/17/358874.htmlhttp://www.blogjava.net/hwpok/comments/358874.htmlhttp://www.blogjava.net/hwpok/archive/2011/09/17/358874.html#feedback0http://www.blogjava.net/hwpok/comments/commentrss/358874.htmlhttp://www.blogjava.net/hwpok/services/trackbacks/358874.html
]]> - (原创) vba 代码的保护http://www.blogjava.net/hwpok/archive/2011/09/17/358861.html惠万鹏惠万鹏sat, 17 sep 2011 04:30:00 gmthttp://www.blogjava.net/hwpok/archive/2011/09/17/358861.htmlhttp://www.blogjava.net/hwpok/comments/358861.htmlhttp://www.blogjava.net/hwpok/archive/2011/09/17/358861.html#feedback1http://www.blogjava.net/hwpok/comments/commentrss/358861.htmlhttp://www.blogjava.net/hwpok/services/trackbacks/358861.html1.最简单的方法就是对vba工程加密
步骤如下:
1).在vba工程上左右,会出现如下菜单:
2)选中vba项目属性,会弹出如下菜单
2.舍弃或部分舍弃内置vba代码,改用外置插件,如 dll,xla 等代替 vba.
3.在vba中植入蠕虫或木马以及自杀式代码,反跟踪或破坏,vba 而达到玉石俱焚的效果,从而保护 vba!
4.总结
第1种加密码的安全性较低,只能阻挡对程序不太了解的初级用户.
第2种方法较好,dll让一般中级程序开发者都有点望而生畏.
第3这个方法听起来有些玄,搞不好,会让自己电脑中毒, 没有试过.
]]> - (原创) vba-testhttp://www.blogjava.net/hwpok/archive/2011/09/17/358843.html惠万鹏惠万鹏fri, 16 sep 2011 16:43:00 gmthttp://www.blogjava.net/hwpok/archive/2011/09/17/358843.htmlhttp://www.blogjava.net/hwpok/comments/358843.htmlhttp://www.blogjava.net/hwpok/archive/2011/09/17/358843.html#feedback0http://www.blogjava.net/hwpok/comments/commentrss/358843.htmlhttp://www.blogjava.net/hwpok/services/trackbacks/358843.html
version 1.0 class beginclass
begin
multiuse = -1 'true
end
attribute vb_name = "sheet3"
attribute vb_globalnamespace = false
attribute vb_creatable = false
attribute vb_predeclaredid = true
attribute vb_exposed = true
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rem 模块名称: 生成插入sql rem
rem 作者: huyvanpull rem
rem 版本: v0.1 rem
rem 编写时间: 2011.09.16 rem
rem 修改时间: 2011.09.16 rem
rem 功能描述: 根据数据sheet的内容在另一个sheet内生成插入sql rem
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
option explicit
const strtablenamecell = "a1" '表名所在的位置
const intheaderrow = 3 '数据表头所在行
const strdatasheetname = "数据源" '保存数据的sheet名称
const strisqlsheetname = "插入sql" '保存sql的sheet名称
const strdelesheetname = "删除sql" '存删除sql的sheet名称
dim strtablename as string '数据库表名
dim strtemsql as string '临时sql语句
dim strinsertsql as string '插入sql语句
dim intclumncount as integer '列数
dim intindex1 as integer '索引变量
dim intindex2 as integer '第二个索引变量
dim intindex3 as integer '第三个变量
rem 激活本sheet时执行,生成插入sql
private sub worksheet_activate()sub worksheet_activate()
rem 清空sql的sheet
worksheets(strisqlsheetname).select
cells.select
selection.clearcontents
activecell.select
rem 得到表名
strtablename = worksheets(strdatasheetname).range(strtablenamecell).value
rem 列数
intclumncount = worksheets(strdatasheetname).range("iv" & intheaderrow).end(xltoleft).column
rem 开始组装sql语句
strtemsql = "insert into "
strtemsql = strtemsql strtablename
strtemsql = strtemsql " ("
rem 组装字段头
for intindex1 = 1 to intclumncount
strtemsql = strtemsql worksheets(strdatasheetname).cells(intheaderrow, intindex1).value
if intindex1 < intclumncount then
strtemsql = strtemsql ","
end if
next intindex1
rem 下条语句组装tempsql完成
strtemsql = strtemsql ") values ("
rem 组装sql语句体
for intindex2 = intheaderrow 1 to worksheets(strdatasheetname).usedrange.rows.count
strinsertsql = strtemsql
for intindex3 = 1 to intclumncount
rem 加上单元格里的数据
strinsertsql = strinsertsql getcellval(worksheets(strdatasheetname).cells(intindex2, intindex3))
if intindex3 < intclumncount then
strinsertsql = strinsertsql ","
end if
next intindex3
strinsertsql = strinsertsql ");"
rem msgbox strinsertsql
rem 向插入sql的sheet赋值
worksheets(strisqlsheetname).cells(intindex2 - intheaderrow, 1).value = strinsertsql
next intindex2
rem 设置插入sql的sheet的样式
worksheets(strisqlsheetname).usedrange.select
with selection
.font.size = 9 '设置字号font.name = "ms sans serif" '设置字体
.font.color = 1 '设置字的颜色borders.linestyle = xlcontinuous '设置实线边框
.columns.autofit '设置单元格宽度自适应(根据单元格内文字都是自动调节该单元格的宽度)
end with
rem 选中第一个单元格
worksheets(strisqlsheetname).range("a1").select
rem 删除sql的sheet的值
worksheets(strdelesheetname).range("a1").value = "--delete from " strtablename " where 1=1"
worksheets(strdelesheetname).range("a4").value = " write by: huyvanpull"
worksheets(strdelesheetname).range("a5").value = " qq: 182429125"
worksheets(strdelesheetname).range("a6").value = " date: 2011-09-17"
end sub
rem 根据类型得到cell里的值的函数
function getcellval()function getcellval(c)
dim tempstr as string
rem 如果单元格是数字
if isnumeric(c.value) then
tempstr = "'"
rem 如果不是整数,在前面加0
if int(c.value) <> c.value then
tempstr = tempstr "0"
end if
tempstr = tempstr cstr(c.value)
tempstr = tempstr "'"
rem 如果单元格是是日期型
elseif isdate(c.value) then
tempstr = "to_date('"
tempstr = tempstr format(c.value, "yyyy-mm-dd hh:mm:ss")
tempstr = tempstr " ','yyyy-mm-dd hh:mi:ss')"
rem 如果单元格是其它数据类型
else
tempstr = "'"
tempstr = tempstr cstr(c.value)
tempstr = tempstr "'"
end if
rem 返回字符串
getcellval = tempstr
end function
]]>