手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>VB>列表

VB数据库数据的选项录入及选项增减与编辑

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!


程序代码如下:

option explicit

dim last as string

dim dd as boolean

private sub form-activate()

dim mark as variant

mark=data1.recordset.bookmark

data1.recordset.movelast

last=data1.recordset("name")

data1.recordset.bookmark=mark

text1.visible=true

dbcombol.visible=false

dbgrid1.visible=false

end sub

private sub form-dblclick() '双击表单打开或关闭选项增减和选项编辑功能

static dd as boolean

dd=not dd '第一次双击打开编辑功能第二次双击关闭编辑功能

if dd then

dbgrid1.visible=true

else

dbgrid1.visible=false

exit sub

end if

end sub

private sub dbgrid1-dblclick() '选择当前项后,再双击删除当前记录选项

data2.recordset.delete

dbcombol.refresh

dbgrid1.refresh

end sub

private sub dbgrid1-lostfocus()

dbcombol.refresh '刷新dbcombol

end sub

private sub command1-click(index as integer)

dim i as integer

select case index

case0'addnew

data1.recordset.addnew

dbcombol.setfocus

dbcombol.visible=true

text1.visible=false

case1'edit

data1.recordset.edit

text1.setfocus

dbcombol.visible=false

text1.visible=true

case2'giveup

data1.recordset.cance1update

data1.refresh

dbcombol.visible=false

text1.visible=true

case3'save

data1.recordset. update

data1.recordset.movelast

last=data1.recordset("name")

data1.refresh

dbcombol.visible=false

text1.visible=true

case4'delete

data1.recordset.delete

data1.refresh

case5'end

end

end select

end sub

private sub dbcombol-keydown

(keycode as integer,shift as integer)

if shift=2 then '按下ctrl-key复制上条记录中的同名字段的内容

if data1.recordset.editmode=dbeditinprogress or

data1.recordset.editmode=dbeditadd

then

dbcombol.text=last

end if

end if

end sub% private sub text1-keydown(keycode as integer,shift as integer)

if shift=2 then '按下ctrl-key复制上条记录中的同名字段的内容

if data1.recordset.editmode=dbeditinprogress or

data1.recordset.editmode=dbeditadd

then

text1.text=last

end if

end if

end sub

   通过上述方法使录入速度进一步得到提高,使用户的功效达到事半功倍的效果。

上一篇: VB中播放WAV文件
下一篇: 在VB6.0中播放GIF动画

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!