初学:程序运行到 FilePut(1, Person, RecCount)报错,请各位大神指点

mini_Gui 2019-08-23 05:35:46
保存代码如下:
Private Sub btnSAVE_Click(sender As Object, e As EventArgs) Handles btnSAVE.Click
Dim Person As AdressList '结构体变量,用于保存文件中的一条记录
Dim RecCount As Integer '文件中的记录总数
Dim I As Integer
If Trim(txtNUM.Text) = "" Then '编号为零,退出本过程
MsgBox("编号不能为空")
txtNUM.Focus()
Exit Sub
End If
txtNUM.Text = Convert.ToString(Val(txtNUM.Text)) '清除文本框中的非数字字符
txtNUM.Text = Mid(txtNUM.Text + " ", 1, 4) '在编号后面补上空格
'返回首记录
If LOF(1) > 0 Then
FileGet(1, Person, 1)
End If
'判断新的编号在记录中是否存在
RecCount = 1
Do While EOF(1) = False
FileGet(1, Person, RecCount)
If Person.NUM = txtNUM.Text And State = "新记录" Then
MsgBox("相同的编号已经存在,请从新设置一个编号")
txtNUM.Text = ""
txtNUM.Focus()
Exit Sub
End If
RecCount = RecCount + 1
Loop
txtNAME.Text = Trim(txtNAME.Text)
If txtNAME.Text.Length = 0 Then
MsgBox("名字不能为空,请注意")
txtNAME.Focus()
Exit Sub
End If
Person.NUM = txtNUM.Text
Person.NAME = txtNAME.Text
Person.SEX = rbdMAN.Checked
Person.CITY = txtCITY.Text
Person.ADRESS = txtADRESS.Text
Person.PHONE = txtPHONE.Text
Person.CELL = txtCELL.Text
'准备写入文件
If State = "新记录" Then
RecCount = LastRec() + 1 '当前记录数 运行到此处报错,内容为{"错误的记录长度。"}
FilePut(1, Person, RecCount) '将新编码,姓名等增加到列表框中
istNAME.Items.Add(txtNUM.Text + "" + txtNAME.Text)

End If
If State = "编辑" Then
FilePut(1, Person, BookMark)
State = "新记录"
'改写列表框的内容
istNAME.Items.Clear()
RecCount = LastRec()
For I = 1 To RecCount
FileGet(1, Person, I)
istNAME.Items.Add(Person.NUM + "" + Person.NAME)

Next
End If
txtNUM.Text = ""
txtNAME.Text = ""
txtCITY.Text = ""
txtADRESS.Text = ""
txtPHONE.Text = ""
txtCELL.Text = ""
rbdMAN.Checked = True
txtNUM.Focus()
End Sub

通用函数过程 LastRec() 如下
Private Function LastRec() As Integer
Dim RecCount As Integer
'文件中的总记录数
Dim Person As AdressList
'结构体变量用于保存文件中的一条记录
If LOF(1) = 0 Then
'如果文件长度为0,则记录数为0
LastRec = 0
Exit Function

End If
RecCount = 1
FileGet(1, Person, RecCount)
Do While EOF(1) = False
RecCount = RecCount + 1
FileGet(1, Person, RecCount)
Loop
MsgBox("当前记录数为:" & istNAME.Items.Count & "" & RecCount & "条")
LastRec = RecCount
End Function
...全文
82 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hztltgg 2019-08-27
  • 打赏
  • 举报
回复
是自学还是老师在教?你这学的是用vb.net的皮去套vb6的写法,可别误入歧途。
public bz &&定义全局变量bz=.f.this.listview1.view=2 &&设置视图显示方式 *将ImageList控件图片赋予Listview控件 this.listview1.Icons=this.imagelist1.objectthis.listview1.smallicons=this.imagelist1.object&&添加列表项key=‘小区信息生成‘=this.listview1.listitems.add(,,key,,1)key=‘大楼信息生成‘=this.listview1.listitems.add(,,key,,1)key=‘房屋信息生成‘=this.listview1.listitems.add(,,key,,1)key=‘小区信息登记‘=this.listview1.listitems.add(,,key,,1)key=‘大楼信息登记‘=this.listview1.listitems.add(,,key,,1)key=‘房屋信息登记‘=this.listview1.listitems.add(,,key,,1)key=‘系统数据设定‘=this.listview1.listitems.add(,,key,,1)在“经营部”的click事件中添加代码为:this.parent.listview1.listItems.clear &&清除数据this.parent.listview1.view=2 &&设置视图显示方式*将ImageList控件图片赋予Listview控件this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.object*添加数据项key=‘小区信息生成‘=this.parent.listview1.listitems.add(,,key,,1)key=‘大楼信息生成‘=this.parent.listview1.listitems.add(,,key,,1)key=‘房屋信息生成‘=this.parent.listview1.listitems.add(,,key,,1)key=‘小区信息登记‘=this.parent.listview1.listitems.add(,,key,,1)key=‘大楼信息登记‘=this.parent.listview1.listitems.add(,,key,,1)key=‘房屋信息登记‘=this.parent.listview1.listitems.add(,,key,,1)key=‘系统数据设定‘=this.parent.listview1.listitems.add(,,key,,1)在“管理部”的事件中添加以下代码为:this.parent.listview1.listItems.clearthis.parent.listview1.view=2this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.objectkey=‘业主信息登记‘=this.parent.listview1.listitems.add(,,key,,2)key=‘人口信息查询‘=this.parent.listview1.listitems.add(,,key,,2)key=‘小区投诉登记‘=this.parent.listview1.listitems.add(,,key,,2)key=‘小区投诉查询‘=this.parent.listview1.listitems.add(,,key,,2)key=‘小区员工管理‘=this.parent.listview1.listitems.add(,,key,,2)key=‘系统数据设定‘=this.parent.listview1.listitems.add(,,key,,2)pjyb=.t.在“工程部”上添加代码为:this.parent.listview1.listItems.clearthis.parent.listview1.view=2this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.objectkey=‘装修队登记‘=this.parent.listview1.listitems.add(,,key,,3)key=‘维修信息登记‘=this.parent.listview1.listitems.add(,,key,,3)key=‘维修信息查询‘=this.parent.listview1.listitems.add(,,key,,3)key=‘装修信息登记‘=this.parent.listview1.listitems.add(,,key,,3)key=‘装修信息查询‘=this.parent.listview1.listitems.add(,,key,,3)pjyb=.t.在“财务部”添加代码为:this.parent.listview1.listItems.clearthis.parent.listview1.view=2this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.objectkey=‘收费登记管理‘=this.parent.listview1.listitems.add(,,key,,4)key=‘水费查询管理‘=this.parent.listview1.listitems.add(,,key,,4)key=‘电费查询管理‘=this.parent.listview1.listitems.add(,,key,,4)key=‘煤气费查询管理‘=this.parent.listview1.listitems.add(,,key,,4)key=‘采暖费查询管理‘=this.parent.listview1.listitems.add(,,key,,4)key=‘其它费用查询管理‘=this.parent.listview1.listitems.add(,,key,,4)pjyb=.t.在“保安部”添加代码为:这this.parent.listview1.listItems.clearthis.parent.listview1.view=2this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.objectkey=‘保安排班管理‘=this.parent.listview1.listitems.add(,,key,,5)key=‘保安排班查询‘=this.parent.listview1.listitems.add(,,key,,5)pjyb=.t.在“经理室”添加代码为:this.parent.listview1.listItems.clearthis.parent.listview1.view=2this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.objectkey=‘小区资源统计‘=this.parent.listview1.listitems.add(,,key,,6)key=‘业主信息查询‘=this.parent.listview1.listitems.add(,,key,,6)key=‘人口信息查询‘=this.parent.listview1.listitems.add(,,key,,6)key=‘小区投诉查询‘=this.parent.listview1.listitems.add(,,key,,6)key=‘小区员工查询‘=this.parent.listview1.listitems.add(,,key,,6)key=‘装修信息查询‘=this.parent.listview1.listitems.add(,,key,,6)key=‘维修信息查询‘=this.parent.listview1.listitems.add(,,key,,6)key=‘保安排班查询‘=this.parent.listview1.listitems.add(,,key,,6)pjyb=.t.在“系统管理”中添加代码为:this.parent.listview1.listItems.clearthis.parent.listview1.view=2this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.objectkey=‘操作员管理‘=this.parent.listview1.listitems.add(,,key,,7)key=‘权限设置‘=this.parent.listview1.listitems.add(,,key,,7)pjyb=.t.在“帮助”中添加代码为:this.parent.listview1.listItems.clearthis.parent.listview1.view=2this.parent.listview1.Icons=this.parent.imagelist1.objectthis.parent.listview1.smallicons=this.parent.imagelist1.objectkey=‘帮助‘=this.parent.listview1.listitems.add(,,key,,8)key=‘关于本软件‘=this.parent.listview1.listitems.add(,,key,,8)pjyb=.t.在“退出”中添加代码为:quit &&退出主程序在Image1的Click事件中添加代码为:this.parent.commdl.filter=‘图片|*.bmp;*.jpg‘ &&设置过滤器this.parent.commdl.showopen &&显示打开对话框this.parent.rq.image2.picture=this.parent.commdl.filename &&显示选定文件的名字3.系统等录界面的设计在项目管理器中添加一个新的表单,名称为Admain在表单中添加一个ImageList 控件,并进行相应的管理员设置。在表单中添加一个Image控件,一个listview控件,一个ImageList控件,两个text控件,三个label控件,一个commandgroup控件。在表单中的init事件中添加代码为:public cn &&定义全局变量cn=0 &&给全局变量赋初值thisform.listview1.view=0 &&设置视图显示方式*将ImageList控件图片赋予Listview控件thisform.listview1.Icons=thisform.imagelist1.objectthisform.listview1.smallicons=thisform.imagelist1.objectselect tabpurview &&选定tabpurview工作区为当前工作区select *;from wuyemanage!tabpurview;where 权限级别=‘1‘;order by tabpurview.操作员姓名;into cursor sysglythisform.text2.value=sysgly.操作员姓名thisform.text1.value=‘‘key=alltrim(sysgly.操作员姓名) &&赋值给变量key=thisform.listview1.listitems.add(,,key,1) &&添加一个列表项select tabpurviewselect *;from wuyemanage!tabpurview;where 权限级别=‘2‘;order by tabpurview.操作员姓名;into cursor gjczydo while !EOF() &&测试当前记录指针是否在文件尾 key=alltrim(gjczy.操作员姓名) =thisform.listview1.listitems.add(,,key,2) &&添加一个列表项 skip &&相对移动记录指针enddoselect tabpurviewselect *;from wuyemanage!tabpurview;where 权限级别=‘3‘;order by tabpurview.操作员姓名;into cursor ybczydo while !EOF() &&测试当前记录指针是否在文件尾 key=alltrim(ybczy.操作员姓名) =thisform.listview1.listitems.add(,,key,3) &&添加一个列表项 skip &&相对移动记录指针enddoselect tabpurviewselect *;from wuyemanage!tabpurview;where 权限级别=‘4‘;order by tabpurview.操作员姓名;into cursor zdydo while !EOF() &&测试当前记录指针是否在文件尾 key=alltrim(zdy.操作员姓名) =thisform.listview1.listitems.add(,,key,4) &&添加一个列表项 skip &&相对移动记录指针enddo在表单的resize事件中添加代码为:purview=val(alltrim(tabpurview.权限级别)) &&根据用户选择设置权限级别pjyb=tabpurview.经营部pglb=tabpurview.管理部pgcb=tabpurview.工程部pcwb=tabpurview.财务部pbab=tabpurview.保安部pjls=tabpurview.经理室psysgl=tabpurview.系统管理manager=alltrim(thisform.text2.value)do form formfdesktop &&调入表单fdesktopthisform.release &&刷新表单在等录的click事件中添加代码为:if empty(操作员姓名) &&判断操作员字段是否为空 thisform.resize &&执行表单的Resize事件 store .t.to pjyb,pglb,pgcb,pcwb,pbab,pjls,psysgl &&给多个内存变量赋予相同的值else seek cname &&查找输入的操作员姓名 set exact on &&设置字符精确比较*判断密码是否正确 if alltrim(tabpurview.密码)!=ppassword cn=cn+1 cmessagetitle=‘系统登录‘ cmessagetext=‘密码错误,重新输入!‘ ndialogtype=4+32 nanswer=messagebox(cmessagetext,ndialogtype,cmessagetitle) do case case nanswer=6 thisform.text1.value=‘‘ thisform.text1.setfocus &&文本框获得焦点 case nanswer=7 messagebox(‘不要乱来!‘,48,‘系统登录‘) thisform.release &&释放表单 endcase if cn=3 thisform.release endif else thisform.resize &&执行表单的Resize事件 endif endifset exact off &&设置字符非精确比较在取消的click事件中添加代码为:cmessagetitle=‘系统登录‘cmessagetext=‘真的想要退出吗?‘nDialogtype=4+32nanswer=messagebox(cMessagetext,nDialogtype,cMessagetitle)if nanswer=6 quitendif在控件listview1中的itemclick事件中添加代码为:LPARAMETERS itemmanager=alltrim(thisform.listview1.selecteditem.text)thisform.text2.value=managerthisform.text1.setfocus 这样,等录界面就完成了。4.经营部设计(1)在项目管理器中创建一个表单,名称为“小区信息生成”,在表单中添加3个label控件,2个spinner控件,1个commandgroup控件。在“开始生成”的click事件中添加代码为:cstart=thisform.spinner1.valuecend=thisform.spinner2.values=alltrim(str(cstart))e=alltrim(str(cend))cpicture=sys(5)+sys(2003)+‘imagesemptyimage.bmp‘cmessagetitle=‘小区信息生成‘cmessagetext=‘确认生成编号为 ‘+s+‘至 ‘+e+‘的小区信息吗?‘ndialogtype=4+32nAnswer=messagebox(cmessagetext,ndialogtype,cmessagetitle)do case case nAnswer=6 i=1 for i=cstart to cend xqno=alltrim(str(i)) select *; from databasewuyemanage!tabxqinfo; where 小区编号==xqno; into cursor lindep if reccount()=0*追加新记录 insert into tabxqinfo values(xqno,‘‘,‘‘,‘‘,0,0,0,0,0,0,‘‘,‘‘,cpicture,ctod(‘‘),ctod(‘‘)) endif endfor messagebox(‘数据保存成功!‘,48,‘小区信息生成‘) thisform.release do form form小区信息登记 &&调入表单 case nAnswer=7 thisform.spinner1.setfocusendcase在“返回主系统”中的click事件中添加代码为:thisform.release &&释放表单(2)在项目管理器中添加一个新的表单名称为“大楼信息生成器”,在表单中添加9个label控件,1个combo控件,2个spinner控件,4个text控件。说明:其编法如(1)(3)在项目管理器中新建一个表单,名称为“房屋信息生成器”,在表单中添加13个label控件,6个combo控件,1个text控件,4个spinner控件,1个commandgroup控件,1个grid控件。说明:其编法如(1)(4)在项目管理器中添加一个新的表单集包含form1,gorm2,名称为“小区信息登记”。在form1表单中添加16个label控件,13个text控件,1个edit控件,2个commandgroup控件,1个common dialog控件,1个image控件,2个command控件,在form2表单中添加1个command控件,1个grid控件。在form1中的load事件中添加代码为:public l &&定义全局变量l=.f.在form1中的activate事件中添加代码为:thisform.text1.value=tabxqinfo.小区编号 &&赋值给Text1thisform.text2.value=tabxqinfo.小区名称thisform.text3.value=tabxqinfo.负责人thisform.text4.value=tabxqinfo.小区说明thisform.text5.value=tabxqinfo.交工日期thisform.text6.value=tabxqinfo.竣工日期thisform.text7.value=tabxqinfo.地址thisform.text8.value=tabxqinfo.占地面积thisform.text9.value=tabxqinfo.建筑面积thisform.text10.value=tabxqinfo.绿化面积thisform.text11.value=tabxqinfo.居住面积thisform.text12.value=tabxqinfo.楼栋数thisform.text13.value=tabxqinfo.总户数thisform.edit1.value=tabxqinfo.备注thisform.container1.image1.picture=tabxqinfo.照片thisform.refresh在form1中的init事件中添加代码为:store l to thisform.text1.enabled,thisform.text2.enabled,thisform.text3.enabled,; thisform.text4.enabled,thisform.text5.enabled,thisform.text6.enabled,; thisform.text7.enabled,thisform.text8.enabled,thisform.text9.enabled,; thisform.text10.enabled,thisform.text11.enabled,thisform.text12.enabled,; thisform.text13.enabled,thisform.edit1.enabled,thisform.badd.enabled,; thisform.bclear.enabled &&设置控件是否有效在form1中的“添加”click事件中添加代码为:if alltrim(thisform.commandgroup1.command1.caption)=‘添 加‘ thisform.commandgroup1.command1.caption=‘保 存‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘取 消‘ thisform.commandgroup1.command3.enabled=.f. thisform.commandgroup1.command4.enabled=.f.*设置控件有效 l=.t. thisform.init &&执行表单的Init事件 store ‘‘ to thisform.text1.value,thisform.text2.value,thisform.text3.value,; thisform.text4.value,thisform.text7.value store {//} to thisform.text5.value,thisform.text6.value store 0 to thisform.text8.value,thisform.text9.value,thisform.text10.value,; thisform.text11.value,thisform.text12.value,thisform.text13.value thisform.edit1.value=‘‘ thisform.container1.image1.picture=sys(5)+sys(2003)+‘imagesemptyimage.bmp‘ thisform.text1.setfocuselse thisform.commandgroup1.command1.caption=‘添 加‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘修 改‘ thisform.commandgroup1.command3.enabled=.t. thisform.commandgroup1.command4.enabled=.t.*获取输入信息 xqno=alltrim(thisform.text1.value) xqname=alltrim(thisform.text2.value) xqinfo=alltrim(thisform.text4.value) fzr=alltrim(thisform.text3.value) jiaogdate=thisform.text5.value jungdate=thisform.text6.value area=alltrim(thisform.text7.value) cmemo=alltrim(thisform.edit1.value) zdmj=thisform.text8.value jzmj=thisform.text9.value lhmj=thisform.text10.value juzmj=thisform.text11.value lds=thisform.text12.value zhs=thisform.text13.value cpicture=thisform.container1.image1.picture select *; from wuyemanage!tabxqinfo; where 小区编号==xqno; order by 小区编号; into cursor lindep if reccount()=0 insert into tabxqinfo values(xqno,xqname,xqinfo,fzr,lds,zhs,jzmj,juzmj,zdmj,; lhmj,area,cmemo,cpicture,jungdate,jiaogdate) &&追加新记录 messagebox(‘数据保存完毕!‘,48,‘操作成功!‘) else cmessagetitle=‘小区信息登记‘ cmessagetext=‘信息已修改,确定要保存吗?‘ ndialogtype=4+32 nAnswer=messagebox(cmessagetext,ndialogtype,cmessagetitle) do case case nAnswer=6 update wuyemanage!tabxqinfo set 小区名称=xqname,小区说明=xqinfo,负责人=fzr,; 楼栋数=lds,总户数=zhs,建筑面积=jzmj,居住面积=juzmj,占地面积=zdmj,地址=area,; 备注=cmemo,照片=cpicture,竣工日期=jungdate,交工日期=jiaogdate,绿化面积=lhmj ; where 小区编号==xqno &&更新数据表 messagebox(‘数据保存完毕!‘,48,‘操作成功!‘) endcase endif select tabxqinfo l=.f. thisform.init &&执行表单的Init事件 thisform.activate &&执行表单的Activate事件endif在form1中的“修改”click事件中添加代码为:if alltrim(thisform.commandgroup1.command2.caption)=‘修 改‘ thisform.commandgroup1.command1.caption=‘保 存‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘取 消‘ thisform.commandgroup1.command3.enabled=.f. thisform.commandgroup1.command4.enabled=.f. l=.t. thisform.init &&执行表单的Init事件 thisform.text1.enabled=.f. thisform.text1.setfocuselse thisform.commandgroup1.command1.caption=‘添 加‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘修 改‘ thisform.commandgroup1.command3.enabled=.t. thisform.commandgroup1.command4.enabled=.t. thisform.activate &&执行表单的Activate事件 l=.f. thisform.init &&执行表单的Init事件endif在form1中的“删除”click事件中添加代码为:xqnumber=alltrim(thisform.text1.value)cmessagetitle=‘小区信息登记‘cmessagetext=‘确定要删除吗?‘ndialogtype=4+32nAnswer=messagebox(cmessagetext,ndialogtype,cmessagetitle)if nAnswer=6 select tabxqinfo use use database/tabxqinfo exclusive &&以独占方式打开数据表 dele from tabxqinfo where 小区编号=xqnumber &&逻辑删除记录 dele from tabxqinfo where empty(小区编号) pack &&物理删除 thisform.activate &&执行表单的Activate事件 messagebox(‘删除完毕‘,48,‘操作成功!‘) use database abxqinfo thisform.refreshendif在form1中的“浏览”click事件中添加代码为:thisform.parent.form2.grid1.recordsource=‘tabxqinfo‘ &&赋数据源thisform.parent.form2.visible=.t. &&显示表单在form1中的“退出”click事件中添加代码为:thisform.release &&释放表单thisform.parent.form2.release在form1中的“追加图片”click事件中添加代码为:thisform.imagedc.filter="图片|*.bmp;*.jpg" &&设置过滤器 thisform.imagedc.showopen &&显示打开对话框thisform.Container1.image1.picture=thisform.imagedc.filename在form1中的“清除图片”click事件中添加代码为:thisform.Container1.image1.picture=sys(5)+sys(2003)+‘imagesemptyimage.bmp‘在form1中的“第一个”click事件中添加代码为:go top &&记录指针定位到第一条记录this.parent.command1.enabled=.f.this.parent.command2.enabled=.f.this.parent.command3.enabled=.t.this.parent.command4.enabled=.t.thisform.Activate &&执行表单的Activatethisform.refresh在form1中的“上一个”click事件中添加代码为: skip-1 &&把记录指针向上移一条记录 thisform.Activate &&执行表单的Activate if bof() messagebox(‘已是第一个记录‘,48,‘信息窗口‘) this.parent.command1.enabled=.f. this.parent.command2.enabled=.f. thisform.Activate &&执行表单的Activate else this.parent.command1.enabled=.t. this.parent.command2.enabled=.t. endif this.parent.command3.enabled=.t. this.parent.command4.enabled=.t.thisform.refresh在form1中的“下一个”click事件中添加代码为:if eof() messagebox(‘已经是最后一条记录‘,48,‘管理窗口‘) skip-1 &&记录指针向上移动一条记录 thisform.Activate &&执行表单的Activate this.parent.command1.enabled=.f. this.parent.command2.enabled=.f. this.parent.command3.enabled=.f. this.parent.command4.enabled=.f.else skip &&记录指针向下移一条记录 thisform.Activate &&执行表单的Activate if eof() messagebox(‘已经是最后一条记录‘,48,‘管理窗口‘) skip-1 thisform.Activate &&执行表单的Activate this.parent.command3.enabled=.f. this.parent.command4.enabled=.f. else this.parent.command3.enabled=.t. this.parent.command4.enabled=.t. endif this.parent.command1.enabled=.t. this.parent.command2.enabled=.t.endifthisform.refresh在form1中的“最后一个”click事件中添加代码为:go bottom &&记录指针移动到最后一条记录this.parent.command3.enabled=.f.this.parent.command4.enabled=.f.this.parent.command1.enabled=.t.this.parent.command2.enabled=.t.thisform.Activate &&执行表单的Activatethisform.refresh在form1中的控件edit1的keypress事件中添加代码为:LPARAMETERS nKeyCode, nShiftAltCtrlif nKeycode=3thisform.text8.setfocusendif在form1中的控件edit1的lostfocus事件中添加代码为:thisform.text8.setfocus在form2中的“退出小区信息浏览”的click事件中添加代码为:thisform.visible=.f. &&隐藏表单(5)在项目管理器中添加一个表单集包括form1,form2,form3,名称为“大楼信息登记”。在表单form1中添加2个list控件,2个label控件,1个commandgroup控件,在表单form2中添加17个label控件,12个text控件,2个combo控件,1个edit控件,1个common dialog控件,1个image控件,2个command控件,2个commandgroup控件,在表单form3中添加1个grid控件, 1个command控件。说明:其编法如以上(4)所示(6)在项目管理器中新建表单集包含form1,form2,form3,名称为“房屋信息登记”。在表单form1中添加1个commbo控件,2个list控件,2个label控件,1个commandgroup控件,在表单form2中添加19个label控件,9个text控件,8个combo控件,1个edit控件,1个commandgroup控件,在表单form3中添加1个grid控件, 1个command控件。说明:其编法如以上(4)所示(7)在项目管理器中添加一个新的表单名称为“系统数据设定”,在表单中添加一个label控件,2个commandgroup控件。在表单的“退出系统数据设定”按钮的click事件中添加代码为:thisform.release在表单的“房屋朝向设定”按钮的click事件中添加代码为:thisform.release &&释放表单do form form房屋朝向设定 &&调入表单在表单的“权限类型设定”按钮的click事件中添加代码为:thisform.release &&释放表单do form form权属类型设定 &&调入表单在表单的“小区部门设定”按钮的click事件中添加代码为:thisform.release &&释放表单do form form小区部门设定 &&调入表单在表单的“员工种类设定”按钮的click事件中添加代码为:thisform.release &&释放表单do form form员工种类设定 &&调入表单元在表单的“费用科目及费用标准设定”按钮的click事件中添加代码为:thisform.release &&释放表单do form form费用科目及费用标准设定 &&调入表单(8)在项目管理器中添加一个新的表单名称为“房屋朝向设计”,表单中添加3个label控件,1个text控件,1个grid控件,1个commandgroup控件。在表单的init事件中添加以下代码:thisform.text1.controlsource=‘tabfrontage.房屋朝向‘ &&赋数据源thisform.grid1.recordsource=‘tabfrontage‘ &&赋数据源在“添加”按钮的click事件中添加代码为:if thisform.commandgroup1.command1.caption=‘添 加‘ thisform.commandgroup1.command1.caption=‘保 存‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘取 消‘ &&赋值给Command2的标题文本 append blank &&追加新记录 thisform.text1.value=‘‘ thisform.text1.setfocuselse thisform.commandgroup1.command1.caption=‘添 加‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘删 除‘ &&赋值给Command2的标题文本endifthisform.refresh &&刷新表单在“删除”按钮的click事件中添加代码为:if thisform.commandgroup1.command2.caption=‘取 消‘ thisform.commandgroup1.command1.caption=‘添 加‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘删 除‘ &&赋值给Command2的标题文本 cx=alltrim(thisform.text1.value) select tabfrontage &&选择Tabfrontage工作区为当前工作区 use &&关闭数据表 use database/tabfrontage exclusive &&以独占方式打开数据表 dele from tabfrontage where 房屋朝向==cx &&逻辑删除记录 dele from tabfrontage where empty(房屋朝向) &&逻辑删除记录 pack &&物理删除 thisform.text1.value=tabfrontage.房屋朝向 use database abfrontage &&打开数据表 else cx=alltrim(thisform.text1.value) select tabfrontage use use database/tabfrontage exclusive &&以独占方式打开数据表 dele from tabfrontage where 房屋朝向==cx &&逻辑删除记录 dele from tabfrontage where empty(房屋朝向) &&逻辑删除记录 pack &&物理删除 thisform.text1.value=tabfrontage.房屋朝向 messagebox(‘删除完毕‘,48,‘操作成功!‘) use database abfrontage &&打开数据表 endif thisform.init &&执行表单的Init事件在text1的click事件中添加代码为:thisform.text1.controlsource=‘tabfrontage.房屋朝向‘thisform.text1.value=alltrim(thisform.grid1.column1.text1.value)(9)在项目管理器中添加一个新的表单名称为“费用科目及费用标准设定设计”,表单中添加4个label控件,2个text控件,1个grid控件,1个commandgroup控件。说明:其编法如以上(8)所示5.管理部设计(1)在项目管理器中添加一个表单集,含有form1,form2.,form3,form4,名称为“业主信息登记”在表单form1中添加1个combo控件,1个list控件,5个label控件,1个commandgroup控件,3个text控件,2个grid控件,1个command控件,1个optioguoup控件。在表单form2中添加1个grid控件, 1个command控件。在表单form3中添加24个label控件,15个text控件,3个combo控件,4个date and time picker控件,1个commandgroup控件,1个grid控件,在表单form4中添加23个label控件,13个text控件,8个combo控件,1个edit控件,1个commandgroup控件。在form1的init事件中添加以下代码:public date1,date2,date3,date4 &&定义全局变量store ctod(‘03/22/2003‘) to date1,date2,date3,date4store .f. to thisform.parent.form3.visible,thisform.parent.form4.visible &&隐藏表单thisform.grid1.columncount=1 &&指定表格的列对象的数目thisform.grid1.column1.header1.caption=‘大楼名称‘store ‘‘ to thisform.grid1.recordsource,thisform.grid1.column1.controlsource,; thisform.list1.controlsource,thisform.list1.rowsource,thisform.grid3.recordsource在form1表单的“小区名称”组合框的interactivechange事件中添加以下代码:thisform.init &&执行表单的Init事件xqname=alltrim(thisform.combo1.displayvalue)select *;from databasewuyemanage!tabdlinfo;where 所属区域==xqname;into cursor lindepingthisform.grid1.columncount=1 &&指定表格的列对象的数目thisform.grid1.column1.header1.caption=‘大楼名称‘thisform.grid1.column1.width=154thisform.grid1.recordsource=‘lindeping‘ &&赋数据源thisform.grid1.column1.controlsource=‘lindeping.大楼名称‘&&赋数据源thisform.refresh 在form1表单的“添加新业主”按钮的click事件中添加代码为:yxq=alltrim(thisform.combo1.displayvalue)ydl=alltrim(thisform.text1.value)yfw=alltrim(thisform.text2.value)if empty(yxq) or empty(ydl) or empty(yfw) messagebox(‘选择小区名称、大楼名称和房屋编号!‘,48,‘操作失败‘)else select tabyzinfo locate for 购入房编号=yfw &&顺序查询 if found() messagebox(‘此房屋已住人!‘,48,‘业主信息登记‘) else thisform.parent.form3.visible=.t. &&显示表单 lfjno=len(yxq)+len(ydl)+1 fjno=substr(yfw,lfjno) thisform.parent.form3.text1.value=yxq thisform.parent.form3.text2.value=ydl thisform.parent.form3.text3.value=fjno thisform.parent.form3.text4.value=yfw thisform.parent.form3.text5.value=yfw store ‘‘ to thisform.parent.form3.text6.value,thisform.parent.form3.text7.value,; thisform.parent.form3.text8.value,thisform.parent.form3.text9.value,; thisform.parent.form3.text10.value,thisform.parent.form3.text11.value,; thisform.parent.form3.text12.value,thisform.parent.form3.text13.value,; thisform.parent.form3.text14.value,thisform.parent.form3.combo1.value,; thisform.parent.form3.combo2.value,thisform.parent.form3.combo3.value thisform.parent.form3.grid1.recordsource=‘‘ thisform.parent.form3.text5.setfocus &&Text5获得焦点 endifendif在form1表单的“修改业主信息”按钮的click事件中添加代码为:cvalue=alltrim(thisform.text3.value)if !empty(cvalue)thisform.parent.form3.visible=.t.public yzdh &&定义全局变量yzdh=alltrim(thisform.text3.value)select *;from wuyemanage!tabyzinfo;where 业主代号==yzdh;into cursor lxgyzinfo*赋值给Text1等thisform.parent.form3.text1.value=lxgyzinfo.小区名称thisform.parent.form3.text2.value=lxgyzinfo.大楼名称thisform.parent.form3.text3.value=lxgyzinfo.房间号码thisform.parent.form3.text4.value=lxgyzinfo.购入房编号thisform.parent.form3.text5.value=lxgyzinfo.业主代号thisform.parent.form3.text6.value=lxgyzinfo.业主姓名thisform.parent.form3.text7.value=lxgyzinfo.手机thisform.parent.form3.text8.value=lxgyzinfo.管理协议书编号thisform.parent.form3.text9.value=lxgyzinfo.电话thisform.parent.form3.text10.value=lxgyzinfo.购房合同书编号thisform.parent.form3.text11.value=lxgyzinfo.联系地址thisform.parent.form3.text12.value=lxgyzinfo.证件号thisform.parent.form3.text13.value=lxgyzinfo.单位电话thisform.parent.form3.text14.value=lxgyzinfo.工作单位thisform.parent.form3.combo1.value=lxgyzinfo.性别thisform.parent.form3.combo2.value=lxgyzinfo.是否进住thisform.parent.form3.combo3.value=lxgyzinfo.证件名*赋值给date and time picker 控件thisform.parent.form3.date1.year=year(lxgyzinfo.签约日期)thisform.parent.form3.date1.month=month(lxgyzinfo.签约日期)thisform.parent.form3.date1.day=day(lxgyzinfo.签约日期)thisform.parent.form3.date2.year=year(lxgyzinfo.进住起始日期)thisform.parent.form3.date2.month=month(lxgyzinfo.进住起始日期)thisform.parent.form3.date2.day=day(lxgyzinfo.进住起始日期)thisform.parent.form3.date3.year=year(lxgyzinfo.进住日期)thisform.parent.form3.date3.month=month(lxgyzinfo.进住日期)thisform.parent.form3.date3.day=day(lxgyzinfo.进住日期)thisform.parent.form3.date4.year=year(lxgyzinfo.进住截止日期)thisform.parent.form3.date4.month=month(lxgyzinfo.进住截止日期)thisform.parent.form3.date4.day=day(lxgyzinfo.进住截止日期)select *;from wuyemanage!tabrkinfo;where 房间编号==alltrim(thisform.parent.form3.text4.value);order by 人口编号;into cursor lincythisform.parent.form3.grid1.recordsource=‘lincy‘ &&赋数据源thisform.parent.form3.text5.setfocus &&Text5获得焦点else messagebox(‘选择业主代号!‘,48,‘业主信息登记‘)endif在form1表单的“删除业主信息”按钮的click事件中添加代码为:yzno=alltrim(thisform.text3.value)cmessagetitle=‘业主信息登记‘cmessagetext=‘确定要删除吗?‘ndialogtype=4+32nAnswer=messagebox(cmessagetext,ndialogtype,cmessagetitle)if nAnswer=6 select tabyzinfo use use database/tabyzinfo exclusive &&以独占的方式打开数据表 dele from tabyzinfo where 业主代号==yzno &&逻辑删除 dele from tabyzinfo where empty(业主代号) pack &&物理删除 update wuyemanage!tabfwinfo set 房主代号=‘‘,房主姓名=‘‘,是否空闲=.t.,房屋状态=‘空闲‘ ; where 房主代号==yzno &&更新数据表 messagebox(‘删除完毕‘,48,‘操作成功!‘) use database abyzinfo thisform.optiongroup1.interactivechange &&执行Optiongroup1的Interactionchange事件 thisform.text3.value=‘‘ thisform.refreshendif在form1表单的“退出业主登记管理”按钮的click事件中添加代码为:thisform.release &&释放表单thisform.parent.form2.releasethisform.parent.form3.releasethisform.parent.form4.release在form1表单的optiongroup1选项按钮组的interactivechange事件中添加代码为:do case case thisform.optiongroup1.option1.value=1 select *; from wuyemanage!tabyzinfo; where 大楼名称==alltrim(thisform.text1.value); into cursor linall thisform.grid3.recordsource=‘linall‘ &&赋数据源 case thisform.optiongroup1.option2.value=1 select *; from wuyemanage!tabyzinfo; where 是否进住==‘已进住‘ and 大楼名称==alltrim(thisform.text1.value); into cursor liny thisform.grid3.recordsource=‘liny‘ &&赋数据源 case thisform.optiongroup1.option3.value=1 select *; from wuyemanage!tabyzinfo; where 是否进住==‘未进住‘and 大楼名称==alltrim(thisform.text1.value); into cursor linw thisform.grid3.recordsource=‘linw‘endcase在form1的“查看房屋详细信息”按钮的click事件中添加以下代码:dlname=alltrim(thisform.text1.value)if !empty(dlname) select *; from database abfwinfo; where 大楼名称==dlname; into cursor lin if reccount()=0 messagebox(‘先生成大楼[‘+dlname+‘]的房屋信息!‘,48,‘操作失败‘) else thisform.parent.form2.grid1.recordsource=‘lin‘ &&赋数据源 endifelse thisform.parent.form2.grid1.recordsource=‘tabfwinfo‘endifthisform.parent.form2.visible=.t. &&显示表单在form1的list1控件的click事件中添加以下代码:thisform.text2.value=alltrim(thisform.list1.displayvalue)在form1的text1控件的click事件中添加以下代码:thisform.text3.value=alltrim(thisform.grid3.column1.text1.value)在form2表单的init事件中添加代码:thisform.grid1.recordsource=‘tabfwinfo‘在form2的“退出房屋信息列表”按钮的click事件中添加以下代码:thisform.visible=.f. &&隐藏表单在form3表单的init事件中添加代码:thisform.grid1.recordsource=‘‘在form3表单的load事件中添加代码:public bzcy在form3的“确定保存业主信息”按钮的click事件中添加以下代码:*获得输入信息yzdh=alltrim(thisform.text5.value)yzname=alltrim(thisform.text6.value)sex=alltrim(thisform.combo1.displayvalue)lxdz=alltrim(thisform.text11.value)sj=alltrim(thisform.text7.value)tel=alltrim(thisform.text9.value)workdw=alltrim(thisform.text14.value)dwtel=alltrim(thisform.text13.value)zjname=alltrim(thisform.combo3.displayvalue)zjnumber=alltrim(thisform.text12.value)sfjz=alltrim(thisform.combo2.displayvalue)gfhtno=alltrim(thisform.text10.value)glxysno=alltrim(thisform.text8.value)fwno=alltrim(thisform.text4.value)xqname=alltrim(thisform.text1.value)dlname=alltrim(thisform.text2.value)fjno=alltrim(thisform.text3.value)if sfjz=‘已进住‘ fwzt=‘入住‘else fwzt=‘签约‘endif*自动编号select tabrkinfoif empty(人口编号) rknumber=alltrim(‘RK00001‘)else select max(人口编号) from tabrkinfo into array a &&查找表tabrkinfo中最大的人口编号存入数组a中 cend=val(substr(a(1),3))+1 rknumber=alltrim(‘RK‘+padl(alltrim(str(cend,5)),5,‘0‘))endifif empty(yzname) or empty(gfhtno) or empty(glxysno) or empty(zjnumber) or empty(zjname) or empty(tel) messagebox(‘将信息添全!‘,48,‘操作失败‘)else select tabyzinfo locate for 业主代号=yzdh &&顺序查询 if !found() insert into tabyzinfo values(yzdh,yzname,sex,lxdz,sj,tel,workdw,dwtel,zjname,zjnumber,; date1,date3,date2,date4,sfjz,gfhtno,glxysno,fwno,xqname,dlname,fjno) &&追加新记录 update wuyemanage!tabfwinfo set 房主代号=yzdh,房主姓名=yzname,是否空闲=.f.,; 房屋状态=fwzt where 房间编号==fwno &&更新数据表 insert into tabrkinfo values(rknumber,yzname,sex,ctod(‘‘),‘1‘,‘‘,‘户主‘,‘‘,‘‘,‘‘,workdw,‘‘,; ‘‘,‘‘,‘‘,dwtel,sj,tel,lxdz,xqname,dlname,fjno,zjnumber,‘‘,‘‘,fwno,‘‘) messagebox(‘数据保存完毕!‘,48,‘业主信息登记‘) thisform.parent.form1.grid1.column1.text1.click &&执行Text1的Click事件 thisform.visible=.f. &&隐藏表单 else update wuyemanage!tabyzinfo set 业主姓名=yzname,性别=sex,联系地址=lxdz,手机=sj,电话=tel,; 工作单位=workdw,单位电话=dwtel,证件号=zjnumber,签约日期=date1,进住日期=date3,; 进住起始日期=date2,进住截止日期=date4,是否进住=sfjz,购房合同书编号=gfhtno,; 管理协议书编号=glxysno,购入房编号=fwno,小区名称=xqname,大楼名称=dlname,; 房间号码=fjno where 业主代号==yzdh &&更新数据表 update wuyemanage!tabfwinfo set 房主代号=yzdh,房主姓名=yzname,是否空闲=.f.,; 房屋状态=fwzt where 房间编号==fwno update wuyemanage!tabrkinfo set 姓名=yzname,性别=sex,工作单位=workdw,单位电话=dwtel,; 手机=sj,传呼=tel,家庭住址=lxdz,身份证号=zjnumber where 房间编号==fwno thisform.parent.form1.grid1.column1.text1.click endifendif在form3表单的“添加成员信息”按钮的click事件中添加代码为:pfjno=alltrim(thisform.text3.value)pfjnumber=alltrim(thisform.text4.value)select *;from wuyemanage!tabrkinfo;where 房间编号==pfjnumber;order by 房间编号;into cursor lincyif reccount()=0 messagebox(‘添加业主信息!‘,48,‘业主信息登记‘)else thisform.parent.form4.text3.value=alltrim(str(reccount()+1)) thisform.parent.form4.visible=.t. store ‘‘ to thisform.parent.form4.text1.value,thisform.parent.form4.text2.value,; thisform.parent.form4.text4.value,thisform.parent.form4.text5.value,; thisform.parent.form4.text6.value,thisform.parent.form4.text7.value,; thisform.parent.form4.text8.value,thisform.parent.form4.text9.value,; thisform.parent.form4.text10.value,thisform.parent.form4.text11.value,; thisform.parent.form4.text12.value,thisform.parent.form4.combo1.value,; thisform.parent.form4.combo2.value,thisform.parent.form4.combo3.value,; thisform.parent.form4.combo4.value,thisform.parent.form4.combo5.value,; thisform.parent.form4.combo6.value,thisform.parent.form4.combo7.value,; thisform.parent.form4.combo8.value,thisform.parent.form4.edit1.value thisform.parent.form4.text13.value={//} bzcy=.t.endifthisform.parent.form1.commandgroup1.command2.click &&执行Command2的Click事件在form3表单的“编辑成员信息”按钮的click事件中添加代码为:public pxq,pdl,pfjno,pfjnumberpxq=alltrim(thisform.text1.value)pdl=alltrim(thisform.text2.value)pfjno=alltrim(thisform.text3.value) &&定义全局变量pfjnumber=alltrim(thisform.text4.value)cvalue=alltrim(thisform.textg.value)if !empty(cvalue) thisform.parent.form4.visible=.t. cynumber=alltrim(thisform.textg.value) select *; from wuyemanage!tabrkinfo; where 人口编号==cynumber; into cursor lcyinfo thisform.parent.form4.text1.value=lcyinfo.姓名 thisform.parent.form4.text2.value=lcyinfo.职务 thisform.parent.form4.text3.value=lcyinfo.成员代号 thisform.parent.form4.text4.value=lcyinfo.身份证号 thisform.parent.form4.text5.value=lcyinfo.传呼 thisform.parent.form4.text6.value=lcyinfo.单位电话 thisform.parent.form4.text7.value=lcyinfo.家庭电话 thisform.parent.form4.text8.value=lcyinfo.暂住证号 thisform.parent.form4.text9.value=lcyinfo.手机 thisform.parent.form4.text10.value=lcyinfo.家庭住址 thisform.parent.form4.text11.value=lcyinfo.户口所在地 thisform.parent.form4.text12.value=lcyinfo.工作单位 thisform.parent.form4.text13.value=lcyinfo.出生日期 thisform.parent.form4.combo1.value=lcyinfo.性别 thisform.parent.form4.combo2.value=lcyinfo.籍贯 thisform.parent.form4.combo3.value=lcyinfo.婚姻状况 thisform.parent.form4.combo4.value=lcyinfo.职业 thisform.parent.form4.combo5.value=lcyinfo.文化程度 thisform.parent.form4.combo6.value=lcyinfo.职称 thisform.parent.form4.combo7.value=lcyinfo.与户主关系 thisform.parent.form4.combo8.value=lcyinfo.国籍 thisform.parent.form4.edit1.value=lcyinfo.备注 thisform.parent.form4.text1.setfocus &&Text1获得焦点 bzcy=.f.else messagebox(‘选择成员名称!‘,48,‘家庭成员信息‘)endif在form3表单的“删除成员信息”按钮的click事件中添加代码为:rknumber=alltrim(thisform.textg.value)cmessagetitle=‘成员信息‘cmessagetext=‘确定要删除吗?‘ndialogtype=4+32nAnswer=messagebox(cmessagetext,ndialogtype,cmessagetitle)if nAnswer=6 select tabrkinfo use use database/tabrkinfo exclusive &&以独占方式打开数据表 dele from tabrkinfo where 人口编号==rknumber &&逻辑删除记录 dele from tabyzinfo where empty(人口编号) pack &&物理删除 messagebox(‘删除完毕‘,48,‘操作成功!‘) use database abrkinfo thisform.parent.form1.commandgroup1.command2.click &&执行Command2的单击事件 thisform.textg.value=‘‘ thisform.refreshendif在form3表单的“退出业主登记”按钮的click事件中添加代码为:thisform.visible=.f. &&隐藏表单在表单form3的 date1控件的init事件中添加代码为:public date1y=alltrim(str(this.year))m=alltrim(str(this.month))d=alltrim(str(this.day))date1=ctod(m+‘/‘+d+‘/‘+y)在表单form3的 date1控件的change事件中添加代码为:*** ActiveX 控件事件 ***y=alltrim(str(this.year))m=alltrim(str(this.month))d=alltrim(str(this.day))date1=ctod(m+‘/‘+d+‘/‘+y)在表单form3的 date2控件的change事件中添加代码为:*** ActiveX 控件事件 ***y=alltrim(str(this.year))m=alltrim(str(this.month))d=alltrim(str(this.day))date2=ctod(m+‘/‘+d+‘/‘+y)在表单form3的 date2控件的init事件中添加代码为:public date2y=alltrim(str(this.year))m=alltrim(str(this.month))d=alltrim(str(this.day))date2=ctod(m+‘/‘+d+‘/‘+y)在表单form3的 date3控件的change事件中添加代码为:y=alltrim(str(this.year))m=alltrim(str(this.month))d=alltrim(str(this.day))date3=ctod(m+‘/‘+d+‘/‘+y)在表单form3的 date3控件的init事件中添加代码为:public date3y=alltrim(str(this.year))m=alltrim(str(this.month))d=alltrim(str(this.day))date3=ctod(m+‘/‘+d+‘/‘+y)在表单form3的 date4控件的change事件中添加代码为:y=alltrim(str(this.year))m=alltrim(str(this.month))d=alltrim(str(this.day))date4=ctod(m+‘/‘+d+‘/‘+y)在表单form3的 date4控件的init事件中添加代码为:y=alltrim(str(thisform.date4.year))m=alltrim(str(thisform.date4.month))d=alltrim(str(thisform.date4.day))date4=ctod(m+‘/‘+d+‘/‘+y)在form4表单的“保存并退出”按钮的click事件中添加代码为:set exact on &&设置字符精确比较*自动编号select tabrkinfoif empty(人口编号) rknumber=alltrim(‘RK00001‘)else select max(人口编号) from tabrkinfo into array a &&查找表中最大的人口编号存入数组 cend=val(substr(a(1),3))+1 rknumber=alltrim(‘RK‘+padl(alltrim(str(cend,5)),5,‘0‘))endif*获得输入信息cname=alltrim(thisform.text1.value)zw=alltrim(thisform.text2.value)cyno=alltrim(thisform.text3.value)sfzno=alltrim(thisform.text4.value)ch=alltrim(thisform.text5.value)dwtel=alltrim(thisform.text6.value)jttel=alltrim(thisform.text7.value)cmemo=alltrim(thisform.edit1.value)zzzno=alltrim(thisform.text8.value)sj=alltrim(thisform.text9.value)area=alltrim(thisform.text10.value)hkszd=alltrim(thisform.text11.value)workdw=alltrim(thisform.text12.value)birthday=thisform.text13.valuesex=alltrim(thisform.combo1.displayvalue)jg=alltrim(thisform.combo2.displayvalue)hyzk=alltrim(thisform.combo3.displayvalue)zy=alltrim(thisform.combo4.displayvalue)whcd=alltrim(thisform.combo5.displayvalue)zc=alltrim(thisform.combo6.displayvalue)yhzgx=alltrim(thisform.combo7.displayvalue)gj=alltrim(thisform.combo8.displayvalue)if empty(cname) or empty(sex) or empty(yhzgx) or empty(area) or empty(hkszd) messagebox(‘将信息填完整!‘,48,‘操作失败‘)else if bzcy=.t. insert into tabrkinfo values(rknumber,cname,sex,birthday,cyno,whcd,yhzgx,jg,gj,; hyzk,workdw,zy,zw,zc,jttel,dwtel,sj,ch,area,pxq,pdl,pfjno,sfzno,hkszd,zzzno,; pfjnumber,cmemo) &&追加新记录 thisform.parent.form1.commandgroup1.command2.click else cmessagetitle=‘家庭成员信息‘ cmessagetext=‘信息已修改,确定要保存吗?‘ ndialogtype=4+32 nAnswer=messagebox(cmessagetext,ndialogtype,cmessagetitle) do case case nAnswer=6 update wuyemanage!tabrkinfo set 姓名=cname,性别=sex,出生日期=birthday,成员代号=cyno,; 文化程度=whcd,与户主关系=yhzgx,籍贯=jg,国籍=gj,婚姻状况=hyzk,工作单位=workdw,职业=zy,; 职务=zw,职称=zc,家庭电话=jttel,单位电话=dwtel,手机=sj,传呼=ch,家庭住址=area,小区名称=pxq,; 大楼名称=pdl,房间号=pfjno,身份证号=sfzno,户口所在地=hkszd,暂住证号=zzzno,房间编号=pfjnumber,; 备注=cmemo where 人口编号==alltrim(thisform.parent.form3.textg.value) &&更新数据表 messagebox(‘数据保存完毕!‘,48,‘操作成功!‘) endcase endif endif thisform.visible=.f. &&隐藏表单在form4表单的“放弃并退出”按钮的click事件中添加代码为:thisform.visible=.f. &&隐藏表单(2) 在项目管理器中新建表单集包含form1,form2,名称为“小区投诉登记”。在表单form1中添加15个label控件,9个text控件,1个edit控件,4个combo控件,2个commandgroup控件,1个command控件。在表单form2中添加1个command控件,1个grid控件。说明:其编法如以上(1)所示6.工程部设计(1)在项目管理器中新建表单集包含form1,form2,名称为“装修信息登记”。在表单form1中添加15个label控件,12个text控件, 2个commandgroup控件。在表单form2中添加1个command控件,1个grid控件。在表单form1的 load事件中添加代码为:public ll=.f.在表单form1的 init事件中添加代码为:thisform.text1.enabled=l &&设置控件是否有效thisform.text2.enabled=lthisform.text3.enabled=lthisform.text4.enabled=lthisform.text5.enabled=lthisform.text6.enabled=lthisform.text7.enabled=lthisform.text8.enabled=lthisform.text9.enabled=lthisform.text10.enabled=lthisform.text11.enabled=lthisform.text12.enabled=lthisform.combo1.enabled=lthisform.edit1.enabled=l在表单form1的 activate事件中添加代码为:thisform.text1.value=tabzxinfo.编号thisform.text2.value=tabzxinfo.申人thisform.text3.value=tabzxinfo.客户thisform.text4.value=tabzxinfo.预算thisform.text5.value=tabzxinfo.装修押金thisform.text6.value=tabzxinfo.装修管理费thisform.text7.value=tabzxinfo.罚金thisform.text8.value=tabzxinfo.验收thisform.text9.value=tabzxinfo.申日期thisform.text10.value=tabzxinfo.退押金时间thisform.text11.value=tabzxinfo.完工日期thisform.text12.value=tabzxinfo.经办人thisform.combo1.displayvalue=tabzxinfo.装修队thisform.edit1.value=tabzxinfo.装修内容thisform.refresh &&刷新表单在form1的“添加”按钮的click事件中添加以下代码:if alltrim(thisform.commandgroup1.command1.caption)=‘添加‘ thisform.commandgroup1.command1.caption=‘保存‘ &&赋值给Command1的标题文本 thisform.commandgroup1.command2.caption=‘取消‘ thisform.commandgroup1.command3.enabled=.f. thisform.commandgroup1.command4.enabled=.f. l=.t. thisform.init &&执行表单的Init事件 thisform.text1.enabled=.f.*自动编号 select tabzxinfo if empty(编号) zxno=alltrim(‘ZX00001‘) else select max(编号) from tabzxinfo into array a &&查找表中最大的编号存入数组 cend=val(substr(a(1),3))+1 zxno=alltrim(‘ZX‘+padl(alltrim(str(cend,5)),5,‘0‘)) endif thisform.text1.value=zxno store 0 to thisform.text4.value,thisform.text5.value,; thisform.text7.value,thisform.text6.value store ‘‘ to thisform.text3.value,thisform.text2.value,thisform.text12.value,; thisform.text8.value,thisform.combo1.value,thisform.edit1.value store {//} to thisform.text9.value,thisform.text10.value,thisform.text11.value thisform.combo1.setfocuselse thisform.commandgroup1.command1.caption=‘添加‘ thisform.commandgroup1.command2.capti
使用VFP读取EXCEL中的数据示例 *!* *****数据导入程序,由“学生基本基本情况表模板.xls”导入数据 *!* ***使用VFP控制EXCEL表,计取中指定列的内容*********** *!* "学生基本基本情况表模板.xls"的数据布局 *!* cells(1,1):“标题” *!* cells(2,1):校区 *!* cells(2,3):学历 *!* cells(2,5):专业 *!* cells(2,6):班级 *!* *!* set safe off set talk on LOCAL inf(4) as String *dele file C:\MyDocu~1\Resume.xlw objExcel = CreateObject("Excel.Application") &&创建一个EXCEL应用程序实例 wjm=getfile("xls") objExcel.Workbooks.Open(wjm) &&调用workbooks(Microsoft Excel 应用程序; 中当前打开的所有 Workbook 对象的集合。); 对象的open方法程序来打开指定的文件,并为; 打开的文件创建一个新的工作簿 *objexcel.visible=.f. ***下面的代码判断出生日期字段的格式是否满足要求*** *IF !varTYPE(objexcel.cells(10,6))="d" * MESSAGEBOX("出生日期字段不满足格式要求,不能导入,将出生日期字段修改为:"+CHR(13); +"mm.dd.yy的格式,如:05.19.83 表示1983年5月19 然后再运行此导入程序") * RETURN *ENDIF inf(1)=substr(objexcel.cells(2,1).value,7)&&校区 Inf(2)=objexcel.cells(2,4).value&&学历 inf(3)=objexcel.cells(2,6).value&&专业 inf(4)=objexcel.cells(2,7).value&&班 LOCAL nrow as Number ,i as Number i=0 *MESSAGEBOX("计算行数") *MESSAGEBOX(objexcel.cells(5,1).value) *MESSAGEBOX(VARTYPE(objexcel.cells(22,1).value)) DO WHILE .t. i=i+1 ?objexcel.cells(i,1).value IF !VARTYPE(objexcel.cells(i,1).value)="C" nrow=i-1 EXIT ENDIF ENDDO *nrow=20 LOCAL arecord(16) *MESSAGEBOX("循环添加记录") USE zlb disinf("zlb.dbf中现有记录"+ALLTRIM(STR(RECCOUNT()))+"条") disinf("正在添加记录") FOR i=4 TO nrow arecord(1)=objexcel.cells(i,1).value&&学号  arecord(2)=objexcel.cells(i,2).value&&姓名 arecord(3)=objexcel.cells(i,3).value&&性别 arecord(4)=objexcel.cells(i,4).value&&籍贯 arecord(5)=objexcel.cells(i,5).value&&民族 *MESSAGEBOX(VARTYPE(objexcel.cells(i,6).value)) IF VARTYPE(objexcel.cells(i,6).value)="C" arecord(6)=RIGHT(objexcel.cells(i,6).value,2)+"/"+"01"+'/'; +LEFT(objexcel.cells(i,6).value,2) ELSE arecord(6)= RIGHT(STR(objexcel.cells(i,6).value,5,2),2); +"/"+"01"+"/"; +LEFT(STR(objexcel.cells(i,6).value,5,2),2) ENDIF &&arecord(6)=IIF(VARTYPE(objexcel.cells(i,6).value)="c",RIGHT(objexcel.cells(i,6).value,2)+"/"+"01"+'/'+LEFT(objexcel.cells(i,6).value,2),; RIGHT(STR(objexcel.cells(i,6).value,5,2),2)+"/"+"01"+'/'+LEFT(STR(objexcel.cells(i,6).value,5,2),2))&&出生年月 arecord(7)=LEFT(ALLTRIM(STR(objexcel.cells(i,8).value,6,0)),6)&&邮政编码 arecord(8)=objexcel.cells(i,7).value&&通讯地址 arecord(9)=objexcel.cells(i,9).value &&收信人 arecord(10)=iif(!ALLTRIM(objexcel.cells(i,10).value)=="",objexcel.cells(i,10).value; ,"无")&&家庭电话 arecord(11)=inf(3)&&专业 arecord(12)=inf(4)&&班级 arecord(13)=objexcel.cells(i,11).value&&寝室号码 arecord(14)=STR(objexcel.cells(i,12).value,7,0)&&寝室电话 arecord(15)=inf(1)&&校区 arecord(16)=inf(2)&&学历 SELECT zlb APPEND FROM ARRAY arecord ENDFOR disinf("zlb.dbf中现有记录"+ALLTRIM(STR(RECCOUNT()))+"条") disinf("记录添加完毕,共添加了"+ALLTRIM(STR(nrow-3))+"条记录,查检") INKEY(3) WAIT CLEAR ****定义日期转换函数,此函数能将各种格式的日期转换成mm/dd/yy的格式**** ****如果要转换的日期只有年和月,则自动添加日为'01'*** *!* FUNCTION datetran *!* PARAMETERS soudate *!* IF VARTYPE(soudate)="N" *!* DO case *!* CASE LEN(souDATE) ***关闭工作簿,退出EXCEL objexcel.quit RELEASE objexcel *!* objexcel.save *!* *objExcel.ActiveWorkbook.saved=.f. *!* objexcel.Quit &&退出 *!* RELEASE objexcel *!* retu
会计学 1 计算机数据库基础及应用 计算机数据库基础及应用PPT学习教案全文共14页,当前为第1页。 任务一 定位记录 定位记录的3种方法: 1.在浏览窗口中定位记录 2.使用命令定位记录 3.菜单定位记录 任务概述 第1页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第2页。 在浏览窗口中定位记录 打开学生情况表的浏览窗口,直接单击记录选择器即可实现定位记录。 如图所示: 第2页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第3页。 2.使用命令定位记录 命令:Go <数值表达式> 功能:将记录指针定位到指定的位置。 说明:<数值表达式>的值为要指向记录 的记录号,其取值为正数。 特殊格式:go top " bottom 功能:将指针定位到首记录或尾记录。 (1)绝对定位 第3页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第4页。 例1: 绝对定位 Use xsqk Go bottom Go 3 Go top use &&定位到尾记录 &&定位到3号记录 &&定位到首记录 第4页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第5页。 (2)相对定位 命令:skip [<数值表达式>] 功能:以当前记录为基点,将记录指针向前 或向后移动指定条记录。 说明: a.若< 数值表达式> 为正,则向记录号 大方向移;超过记录号范围 b.若< 数值表达式> 为负,则向记录号 小的方向移; c.若为1,可简写为Skip。 第5页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第6页。 例2: 相对定位记录 Use xsqk Skip Skip 3 Skip -2 use &&定位到5号记录 &&定位到3号记录 &&定位到下一条记录即2号记录 第6页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第7页。 (4)条件定位 命令:locate [<范围>][] continue 功能:在当前数据表中按记录顺序依次查找满足条件 的第1条记录,然后使用continue命令继续查找。 说明:若没找到满足条件的记录,指针指到文件尾。 查找测试函数:Found() 功能:测试最后一次条件查找是否找到,找到为.T. 反之为.F. 第7页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第8页。 3.菜单定位记录 具体操作步聚: 打开要操作的表。 单击"显示"—>"浏览"菜单,打开浏览窗口。 单击"表"—>"转到记录"菜单,弹出下一级菜单。 根据而要选择相应的菜单项。 第8页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第9页。 菜单项与命令操作的对应关系如图: 第一个(T) 最后一个(B) 下一个(N) 上一个(p) 记录号(R) 定位 (L) ————go top ————go bottom ————ship ————skip -1 ————go n ————locate for 第9页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第10页。 练习与思考 1.填空题 (1)定位记录就是将指针移到相应的记录上,按定位的方式分为____________________ _______,其命令关键字分别是 (2)Go top 命令的作用是 2.判断题 ( )(1)相对定位是以当前记录为基准,向上或向下移 动记录指针。 ( )(2)表文件头就是表的首记录,文件尾就是尾记录。 ( )(3)当数据表刚打开时,记录指针指妻文件头, Bof()的值为.T. ( )(4) go <数值表达式> 中,数值表达式的值不能超过最大记录号。 3. 写出下列 第10页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第11页。 (3)相关函数 Record() 功能:测试当前记录的记录号。 说明:当指针指到文件头或表中无记录时,函数值为 1。 当指针指到文件尾时,函数值为最大记录号加 1。 Reccount() 功能:测试当前表的记录总数。 说明:当表无记录时,函数值为 0。 Bof () 功能:测试记录指针是否到了文件头。是为.T. 反之为.F. Eof() 功能:测试记录指针是不到了文件尾。是为.F. 反之为.F. 表中无记录时,bof()和eof()都为真。 第11页/共14页 计算机数据库基础及应用PPT学习教案全文共14页,当前为第12页。 数据表文件中的记录范围与记录指针的移动关系如图所示: 文件头 首记录 . . . 第i条记录 . . . 尾记录 文件尾 skip -1 Go top Go i Go bottom skip Bof()=.T.

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧