| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 569 人关注过本帖
标题:代码写太繁琐了
只看楼主 加入收藏
btchongzi
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2006-8-22
收藏
 问题点数:0 回复次数:9 
代码写太繁琐了
我写了个代码来货物是否存在,并修改。但是实在是太长,不知道各位有什么好点子没
代码如下
LOCATE FOR 分类=txt分类
IF eof() then
appe blan
replace 分类 with txt分类
replace 库存编号 with c
replace 货物名称 with txt货物名称
replace 规格型号 with txt规格型号
replace 生产厂家 with txt生产厂家
replace 计量单位 with txt计量单位
replace 单价 with txt单价
replace 库存数量 with txt入库数量
replace 金额 with txt金额
replace 备注 with edt备注
else
LOCATE FOR 货物名称=txt货物名称
IF eof() then
appe blan
replace 分类 with txt分类
replace 库存编号 with c
replace 货物名称 with txt货物名称
replace 规格型号 with txt规格型号
replace 生产厂家 with txt生产厂家
replace 计量单位 with txt计量单位
replace 单价 with txt单价
replace 库存数量 with txt入库数量
replace 金额 with txt金额
replace 备注 with edt备注
else
LOCATE FOR 生产厂家=txt生产厂家
IF eof() then
appe blan
replace 分类 with txt分类
replace 库存编号 with c
replace 货物名称 with txt货物名称
replace 规格型号 with txt规格型号
replace 生产厂家 with txt生产厂家
replace 计量单位 with txt计量单位
replace 单价 with txt单价
replace 库存数量 with txt入库数量
replace 金额 with txt金额
replace 备注 with edt备注
else
LOCATE FOR 规格型号=txt规格型号
IF eof() then
appe blan
replace 分类 with txt分类
replace 库存编号 with c
replace 货物名称 with txt货物名称
replace 规格型号 with txt规格型号
replace 生产厂家 with txt生产厂家
replace 计量单位 with txt计量单位
replace 单价 with txt单价
replace 库存数量 with txt入库数量
replace 金额 with txt金额
replace 备注 with edt备注
else
replace 库存数量 with 库存数量+txt入库数量
ENDIF
ENDIF
ENDIF
ENDIF
搜索更多相关主题的帖子: 代码 
2006-08-31 17:30
shouting
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-5-27
收藏
得分:0 

2006-08-31 19:45
Tiger5392
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:88
帖 子:2775
专家分:2237
注 册:2006-5-17
收藏
得分:0 

用逻辑变量(逻辑真)表示需要增加记录的地方,程序的最后判断这些逻辑变量然后实施增加。
不过我感觉你的程序存在问题,有点怪怪的。

[此贴子已经被作者于2006-8-31 21:18:19编辑过]


感言:学以致用。 博客:http://www./blog/user14/65009/index.shtml email:Tiger5392@
2006-08-31 21:15
chen1004
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-8-14
收藏
得分:0 
replace 分类 with txt分类
replace 库存编号 with c
replace 货物名称 with txt货物名称
replace 规格型号 with txt规格型号
replace 生产厂家 with txt生产厂家
replace 计量单位 with txt计量单位
replace 单价 with txt单价
replace 库存数量 with txt入库数量
replace 金额 with txt金额
replace 备注 with edt备注
是初学者吧?可以这样写:
replace 分类 with txt分类,库存编号 with c,货物名称 with txt货物名称,规格型号 with txt规格型号,;
生产厂家 with txt生产厂家,计量单位 with txt计量单位,单价 with txt单价,库存数量 with txt入库数量,;
金额 with txt金额,备注 with edt备注

2006-09-01 08:47
啸凡
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:1356
专家分:885
注 册:2006-2-22
收藏
得分:0 
呵呵,我估计这段代码执行不了。因为txt分类、txt货物名称……只是文本框名称,不是文本框的值。

两人行已有我师……
2006-09-01 08:50
啸凡
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:1356
专家分:885
注 册:2006-2-22
收藏
得分:0 
按照楼主的意思,只要找不到相应的分类、货物名称、生产厂家及规格型号的任意一个,就增加一个记录,那么以下几条语句就够了:
Locate For Allt(分类)<>Allt(ThisForm.txt分类.value) OR Allt(货物名称)<>Allt(ThisForm.txt名称.value);
OR Allt(生产厂家)<>Allt(ThisForm.txt生产厂家.value) OR Allt(规格型号)<>Allt(ThisForm.txt规格型号.value)
IF EOF()
Append Blank
replace 分类 with ThisForm.txt分类.value,库存编号 with c,货物名称 with ThisFrom.txt货物名称.value……
ENDIF

两人行已有我师……
2006-09-01 09:54
lndsqfyq
Rank: 1
等 级:新手上路
帖 子:232
专家分:0
注 册:2006-1-16
收藏
得分:0 
用数组。

2006-09-01 09:59
zero07
Rank: 1
等 级:新手上路
帖 子:67
专家分:0
注 册:2006-5-10
收藏
得分:0 

或用表


2006-09-01 11:10
btchongzi
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2006-8-22
收藏
得分:0 

谢谢楼上各位,我把啸凡的代码改了下用上了,我的“txt货物名称”不是名称是文本框的值

Locate For 分类=txt分类 and 货物名称=txt货物名称 and 生产厂家=txt生产厂家 and 规格型号=txt规格型号
IF eof()
appe blan
replace 分类 with txt分类,库存编号 with c,货物名称 with txt货物名称,规格型号 with txt规格型号,生产厂家 with txt生产厂家,计量单位 with txt计量单位,库存数量 with txt入库数量,备注 with edt备注
ELSE
replace 库存数量 with 库存数量+txt入库数量
endif

我还真不知道能这样用,没知识真可怕

[此贴子已经被作者于2006-9-1 16:09:07编辑过]

2006-09-01 15:53
快速回复:代码写太繁琐了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026796 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved