|
如何实现数据的自动录入
来源:不详 作者 佚名 点击数: 录入时间:07-12-19 21:20:43
用户录入数据时经常会遇到大量重复数据,即录入下一条记录的某个字段时,其值与上一条记录同字段的值相同。如果编些程序自动录入相同值会大大提高录入速度。具体实现方法如下:一、程序中主要用到的函数1、FileOpen() 功能:以指定的读写模式打开指定的文件,同时返回文件的句柄。2、FileWrite() 功能:从指定文件读取数据。3、FileClose() 功能:关闭先前用FileOpen()函数打开的文件。4、settext() 功能:得到当前行和列之上的编辑框中的值。5、gettext() 功能:替换在DataWindow控件或DataStore对象的当前行列的编辑框控件中的文本。6、send() 功能:向窗口发送指定的消息并立即执行相应的事件处理程序。7、describe() 功能:返回DataWindow对象或Datastore对象中的其它对象的属性值。以上函数在有关Pb的函数书中均可以找到,这里不再详述,但要注意后面两个函数的使用方法。二、具体实现方法1、建立window具体控件名称如图1所示。 2、定义实例变量数组 string is_value[] 和 integer if_File(存放打开文件的句柄)string is_columncount3、在window的Open事件中编写如下代码int iif_File = FileOpen("Sys.ini",LineMode!, Read!, LockRead!)is_columncount = dw_input.Describe("DataWindow.Column.Count") //取得DataWindow对象的总列数for i = 1 to integer(is_columncount)FileRead(if_File, is_value[i])nextFileClose(if_File)dw_input.Scrolltorow(dw_input.rowcount()) //将光标设置到最后行列dw_input.setcolumn(integer(is_columncount)) 在window 的Close事件中编写如下代码int iif_File = FileOpen("Sys.ini",LineMode!, Write!, LockWrite!, Replace!)for i = 1 to integer(is_columncount)FileWrite(if_File, is_value[i])nextFileClose(if_File)4、给Datawindow control自定义一个回车键事件:Event name: ue_keyenter Event ID: pbm_dwnprocessenter 5、在Datawindow control的ue_keyenter事件中写入以下代码is_value[this.getcolumn()] = this.gettext()Send(Handle(this),256,9,Long(0,0))this.settext(is_value[this.getcolumn()])return 1在Datawindow control的cons[1] [2] 下一页 更多精彩:学习网->http://www.haohao888.com.cn 网络编程->http://www.51wlpc.com 电脑设备->http://www.xpmaster.cn
|