回 帖 发 新 帖 刷新版面

主题:不执行,为什么???

USE 通讯录.dbf
LOCATE FOR 姓名=THISFORM.PAGEFRAME1.PAGE1.TEXT1.VALUE
     IF found()
               X1=messagebox("此人资料已存在!",48,"提示窗口")
               thisform.pageframe1.page1.text1.value=""
               thisform.pageframe1.page1.text2.value=""
               thisform.pageframe1.page1.text3.value=""
               thisform.pageframe1.page1.text4.value=""
               thisform.pageframe1.page1.text5.value=""
               thisform.pageframe1.page1.text6.value=""
               thisform.pageframe1.page1.optiongroup1.option1.value=0
               thisform.pageframe1.page1.optiongroup1.option2.value=0
               thisform.pageframe1.page1.text1.setfocus 
       ELSE     
            IF EMPTY(thisform.pageframe1.page1.text1.value)
               X2=messagebox("联系人姓名不能为空!",48,"提示信息")
            ELSE
               append blank
               replace 姓名 with thisform.pageframe1.page1.text1.value
               replace 单位 with thisform.pageframe1.page1.text2.value
               replace 手机 with thisform.pageframe1.page1.text3.value
               replace 小灵通 with thisform.pageframe1.page1.text4.value
               replace 座机 with thisform.pageframe1.page1.text5.value
               replace 备注 with thisform.pageframe1.page1.text6.value
                 IF thisform.pageframe1.page1.optiongroup1.option1.value=1
                    replace 性别 with "男"
                 ELSE 
                    replace 性别 with "女"
                 ENDIF
              X3=messagebox("资料已成功保存!",48,"信息窗口")
               thisform.pageframe1.page1.text1.value=""
               thisform.pageframe1.page1.text2.value=""
               thisform.pageframe1.page1.text3.value=""
               thisform.pageframe1.page1.text4.value=""
               thisform.pageframe1.page1.text5.value=""
               thisform.pageframe1.page1.text6.value=""
               thisform.pageframe1.page1.optiongroup1.option1.value=0
               thisform.pageframe1.page1.optiongroup1.option2.value=0
               thisform.pageframe1.page1.text1.setfocus
        ENDIF                           
   ENDIF 
USE
问题是: 为什么不执行LOCATE FOR 姓名=THISFORM.PAGEFRAME1.PAGE1.TEXT1.VALUE。
      就是通讯录.DBF中已存在的记录,LOCATE FOR 姓名=THISFORM.PAGEFRAME1.PAGE1.TEXT1.VALUE找不到呢?

回复列表 (共5个回复)

沙发

LOCATE FOR alltrim(姓名)=alltrim(THISFORM.PAGEFRAME1.PAGE1.TEXT1.VALUE)

try again

板凳

LOCATE FOR alltrim(姓名)==alltrim(THISFORM.PAGEFRAME1.PAGE1.TEXT1.VALUE)

3 楼

可以了,但是不明白,为什么非要加alltrim不可呢? 
另外,我是刚刚自学 VF, 请高手以后多多指点,我的QQ 是 7490654,谢谢

4 楼

[quote]可以了,但是不明白,为什么非要加alltrim不可呢? 
另外,我是刚刚自学 VF, 请高手以后多多指点,我的QQ 是 7490654,谢谢
[/quote]

加 alltrim 是去掉字符串的前后空格,

再作:

=    不完全,比较方式。
?"A1234"="A1234"  && 相等 
?"A1234"="A12"     && 这样也相等
 


==  完全,比较方式。
?"A1234"=="A12" && 不相等

?"A1234"=="A1234" && 必须这样才相等。

5 楼

USE 通讯录.dbf
with  thisform.pageframe1.page1
LOCATE FOR alltrim(姓名)==alltrim(.TEXT1.VALUE)
IF found() 
   X1=messagebox("此人资料已存在!",48,"提示窗口")
   store "" to .text1.value, .text2.value, .text3.value,.text4.value, .text5.value,.text6.value
   store 0 to .optiongroup1.option1.value, .optiongroup1.option2.value
   .text1.setfocus 
ELSE     
  IF EMPTY(.text1.value)
     X2=messagebox("联系人姓名不能为空!",48,"提示信息")
  ELSE
    append blanks
    repl 姓名 with .text1.value,单位 with .text2.value,手机 with .text3.value,小灵通 with .text4.value,;
    repl 座机 with .text5.value,备注 with .text6.value,性别 with iif(.optiongroup1.option1.value=1,"男","女")
    X3=messagebox("资料已成功保存!",48,"信息窗口")
    store "" to .text1.value,.text2.value,.text3.value,.text4.value,.text5.value,.text6.value
    store 0 to .optiongroup1.option1.value,.optiongroup1.option2.value
    .text1.setfocus
  ENDIF                           
ENDIF
endwith
USE

我来回复

您尚未登录,请登录后再回复。点此登录或注册