| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 644 人关注过本帖
标题:表单方法事件2
只看楼主 加入收藏
tjdeming
Rank: 2
等 级:论坛游民
帖 子:429
专家分:54
注 册:2013-3-4
结帖率:90.14%
收藏
已结贴  问题点数:20 回复次数:8 
表单方法事件2
在运行表单时,点击引用、引用2命令按钮时没有成功,出现了错误。
程序1.rar (1.16 KB)

错误之处请予以指正 不胜感激!
搜索更多相关主题的帖子: 引用 方法 表单 事件 错误 
2023-08-31 20:15
schtg
Rank: 12Rank: 12Rank: 12
来 自:Usa
等 级:贵宾
威 望:67
帖 子:1744
专家分:3333
注 册:2012-2-29
收藏
得分:0 
回复 楼主 tjdeming
你的出现什么错误?我测试是正常的啊
图片附件: 游客没有浏览图片的权限,请 登录注册
2023-09-01 06:25
tjdeming
Rank: 2
等 级:论坛游民
帖 子:429
专家分:54
注 册:2013-3-4
收藏
得分:0 
回复 2楼 schtg
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册
是VFP6.0
2023-09-01 20:22
schtg
Rank: 12Rank: 12Rank: 12
来 自:Usa
等 级:贵宾
威 望:67
帖 子:1744
专家分:3333
注 册:2012-2-29
收藏
得分:5 
回复 3楼 tjdeming
你的变量赋值在此处
图片附件: 游客没有浏览图片的权限,请 登录注册

应该是先单击 pageframe1之后才单击“引用”或“引用2”。
若不单击pageframe1就可以的话,需要更换赋值位置,或更换赋值来源哈。

[此贴子已经被作者于2023-9-1 20:37编辑过]

2023-09-01 20:31
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:790
专家分:1170
注 册:2021-10-13
收藏
得分:0 
回复 4楼 schtg
改在表单的init事件中赋值吧。。。
2023-09-01 20:46
tjdeming
Rank: 2
等 级:论坛游民
帖 子:429
专家分:54
注 册:2013-3-4
收藏
得分:0 
回复 5楼 sam_jiang
公有变量放在了表单INIT了,原出现的错误没解决,还增加了单击页框时显示空白了
TEXT1是数据型二个组合框也是数据型,VFP6.0. 搞了二个晚上没有解决问题。求助一下。谢谢你!
程序代码:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
    Top = 88
    Left = 85
    Height = 229
    Width = 509
    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"


    ADD OBJECT pageframe1 AS pageframe WITH ;
        ErasePage = .T., ;
        PageCount = 4, ;
        Top = 108, ;
        Left = 36, ;
        Width = 444, ;
        Height = 104, ;
        Name = "Pageframe1", ;
        Page1.Caption = "Page1", ;
        Page1.Name = "Page1", ;
        Page2.Caption = "Page2", ;
        Page2.Name = "Page2", ;
        Page3.Caption = "Page3", ;
        Page3.Name = "Page3", ;
        Page4.Caption = "Page4", ;
        Page4.Name = "Page4"


    ADD OBJECT text1 AS textbox WITH ;
        Alignment = 3, ;
        Value = 0, ;
        Height = 25, ;
        InputMask = "", ;
        Left = 97, ;
        Top = 12, ;
        Width = 96, ;
        Name = "Text1"


    ADD OBJECT label1 AS label WITH ;
        AutoSize = .T., ;
        Caption = "输入编号", ;
        Height = 16, ;
        Left = 24, ;
        Top = 20, ;
        Width = 50, ;
        Name = "Label1"


    ADD OBJECT combo1 AS combobox WITH ;
        RowSourceType = 1, ;
        RowSource = "202301,202302,202303,202304,202305,202306,202307,202308,202309,202310,202311,202312", ;
        Height = 25, ;
        Left = 96, ;
        Top = 60, ;
        Width = 97, ;
        Name = "Combo1"


    ADD OBJECT combo2 AS combobox WITH ;
        RowSourceType = 1, ;
        RowSource = "202301,202302,202303,202304,202305,202306,202307,202308,202309,202310,202311,202312", ;
        Height = 25, ;
        Left = 276, ;
        Top = 60, ;
        Width = 97, ;
        Name = "Combo2"


    ADD OBJECT label2 AS label WITH ;
        Caption = "起始时间", ;
        Height = 13, ;
        Left = 24, ;
        Top = 65, ;
        Width = 61, ;
        Name = "Label2"


    ADD OBJECT label3 AS label WITH ;
        Caption = "终止时间", ;
        Height = 13, ;
        Left = 204, ;
        Top = 65, ;
        Width = 61, ;
        Name = "Label3"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 36, ;
        Left = 432, ;
        Height = 25, ;
        Width = 61, ;
        Caption = "关闭", ;
        Name = "Command1"

  
    ADD OBJECT command2 AS commandbutton WITH ;
        Top = 16, ;
        Left = 332, ;
        Height = 25, ;
        Width = 61, ;
        Caption = "引用", ;
        Name = "Command2"
  
    ADD OBJECT command3 AS commandbutton WITH ;
        Top = 16, ;
        Left = 240, ;
        Height = 25, ;
        Width = 61, ;
        Caption = "引用2", ;
        Name = "Command3"
       
  
    PROCEDURE pageframe1.Click
*!*             PUBLIC nText,ST,ET, RIQI
*!*            *!* public 声明的变量要释放,不然表单关闭了,它们依然存在。
*!*           nText= thisform.TEXT1.value &&此值本来就是0,跟上一句是重复的
*!*            st = *!*            et = *!*            RIQI="J1,J2,J3,J4"
*!*           
*!*             ** 注意到你对3个变量赋值
     ENDPROC

   PROCEDURE INIT
         PUBLIC nText,ST,ET, RIQI
       Text= thisform.TEXT1.value
        st =  = ="J1,J2,J3,J4"
      
     ENDPROC

    PROCEDURE pageframe1.Page1.Click
      * this.parent.click()
        thisform.pageframe1.page1.caption=STR(NTEXT)
       ThisForm.Refresh
    ENDPROC


    PROCEDURE pageframe1.Page2.Click
       * this.parent.click()
      thisform.pageframe1.page2.caption=st
      ThisForm.Refresh
    ENDPROC


    PROCEDURE pageframe1.Page3.Click
      *  this.parent.click()
        thisform.pageframe1.page3.caption=ET
         ThisForm.Refresh
    ENDPROC


    PROCEDURE pageframe1.Page4.Click
      * this.parent.click
        thisform.pageframe1.page4.caption=ET+ST
         ThisForm.Refresh
    ENDPROC


PROCEDURE command2.Click
      =str(ntext)
ENDPROC

PROCEDURE command3.Click
  =RIQI
ENDPROC


 PROCEDURE command1.Click
   CLEAR MEMORY **退出前释放public申明过的变量
   clear
   quit

 ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
2023-09-02 21:13
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:790
专家分:1170
注 册:2021-10-13
收藏
得分:0 
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
    Top = 88
    Left = 85
    Height = 229
    Width = 509
    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"


    ADD OBJECT pageframe1 AS pageframe WITH ;
        ErasePage = .T., ;
        PageCount = 4, ;
        Top = 108, ;
        Left = 36, ;
        Width = 444, ;
        Height = 104, ;
        Name = "Pageframe1", ;
        Page1.Caption = "Page1", ;
        Page1.Name = "Page1", ;
        Page2.Caption = "Page2", ;
        Page2.Name = "Page2", ;
        Page3.Caption = "Page3", ;
        Page3.Name = "Page3", ;
        Page4.Caption = "Page4", ;
        Page4.Name = "Page4"


    ADD OBJECT text1 AS textbox WITH ;
        Alignment = 3, ;
        Value = 0, ;
        Height = 25, ;
        InputMask = "", ;
        Left = 97, ;
        Top = 12, ;
        Width = 96, ;
        Name = "Text1"


    ADD OBJECT label1 AS label WITH ;
        AutoSize = .T., ;
        Caption = "输入编号", ;
        Height = 16, ;
        Left = 24, ;
        Top = 20, ;
        Width = 50, ;
        Name = "Label1"


    ADD OBJECT combo1 AS combobox WITH ;
        RowSourceType = 1, ;
        RowSource = "202301,202302,202303,202304,202305,202306,202307,202308,202309,202310,202311,202312", ;
        Height = 25, ;
        Left = 96, ;
        Top = 60, ;
        Width = 97, ;
        Name = "Combo1"


    ADD OBJECT combo2 AS combobox WITH ;
        RowSourceType = 1, ;
        RowSource = "202301,202302,202303,202304,202305,202306,202307,202308,202309,202310,202311,202312", ;
        Height = 25, ;
        Left = 276, ;
        Top = 60, ;
        Width = 97, ;
        Name = "Combo2"


    ADD OBJECT label2 AS label WITH ;
        Caption = "起始时间", ;
        Height = 13, ;
        Left = 24, ;
        Top = 65, ;
        Width = 61, ;
        Name = "Label2"


    ADD OBJECT label3 AS label WITH ;
        Caption = "终止时间", ;
        Height = 13, ;
        Left = 204, ;
        Top = 65, ;
        Width = 61, ;
        Name = "Label3"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 36, ;
        Left = 432, ;
        Height = 25, ;
        Width = 61, ;
        Caption = "关闭", ;
        Name = "Command1"

  
    ADD OBJECT command2 AS commandbutton WITH ;
        Top = 16, ;
        Left = 332, ;
        Height = 25, ;
        Width = 61, ;
        Caption = "引用", ;
        Name = "Command2"
  
    ADD OBJECT command3 AS commandbutton WITH ;
        Top = 16, ;
        Left = 240, ;
        Height = 25, ;
        Width = 61, ;
        Caption = "引用2", ;
        Name = "Command3"
      
  
    PROCEDURE pageframe1.Click
*!*             PUBLIC nText,ST,ET, RIQI
*!*            *!* public 声明的变量要释放,不然表单关闭了,它们依然存在。
            nText= thisform.TEXT1.value &&此值本来就是0,跟上一句是重复的
            st =
            et =
            RIQI="J1,J2,J3,J4"
           
             *!* 注意到你对3个变量赋值
     
     ENDPROC

   PROCEDURE INIT
         PUBLIC nText,ST,ET, RIQI
*!*               nText= thisform.TEXT1.value
*!*            st =
*!*            et =
*!*            RIQI="J1,J2,J3,J4"
      
     ENDPROC

    PROCEDURE pageframe1.Page1.Click
         this.parent.click()
        thisform.pageframe1.page1.caption=STR(NTEXT)
       ThisForm.Refresh
    ENDPROC


    PROCEDURE pageframe1.Page2.Click
      this.parent.click()
      thisform.pageframe1.page2.caption=st
      ThisForm.Refresh
    ENDPROC


    PROCEDURE pageframe1.Page3.Click
        this.parent.click()
        thisform.pageframe1.page3.caption=ET
         ThisForm.Refresh
    ENDPROC


    PROCEDURE pageframe1.Page4.Click
       this.parent.click
        thisform.pageframe1.page4.caption=ET+ST
         ThisForm.Refresh
    ENDPROC


PROCEDURE command2.Click
      thisform.pageframe1.click() &&给变量赋值
      (str(ntext))
ENDPROC

PROCEDURE command3.Click
    thisform.pageframe1.click() &&给变量赋值
  
ENDPROC


 PROCEDURE command1.Click
   CLEAR MEMORY *!*退出前释放public申明过的变量
    thisform.release

 ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************

多用调试器,可以查看变量的值。。。

[此贴子已经被作者于2023-9-2 23:31编辑过]

2023-09-02 23:29
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:790
专家分:1170
注 册:2021-10-13
收藏
得分:15 
回复 6楼 tjdeming
[引用]公有变量放在了表单INIT了,原出现的错误没解决,还增加了单击页框时显示空白了
TEXT1是数据型二个组合框也是数据型,VFP6.0. 搞了二个晚上没有解决问题。求助一下。谢谢你!
   

    PROCEDURE pageframe1.Click
*!*这段代码被你注释掉了,也就是说你的4个变量在init中初始化,当你改变form上combo和textbox的值的时候,并没有传给你的4个变量

        在这里给四个变量赋值           
            nText= thisform.TEXT1.value
            st =
            et =
            RIQI="J1,J2,J3,J4"
      

     ENDPROC

   PROCEDURE INIT
         PUBLIC nText,ST,ET, RIQI
  *!*下面四句放在pageframe的click里面吧
   *!*   Text= thisform.TEXT1.value 你这里错了,应该是ntext,而不是text
   *!*      st =
   *!*      et =
   *!*      RIQI="J1,J2,J3,J4"
      
     ENDPROC

PROCEDURE command2.Click
*!* 执行这个事件的时候,并没有对变量进行赋值,所以要调用pageframe的click事件
thisform.pageframe1.click()     
(ntext)
ENDPROC

PROCEDURE command3.Click
*!* 执行这个事件的时候,并没有对变量进行赋值,所以要调用pageframe的click事件
thisform.pageframe1.click()
  
ENDPROC

 PROCEDURE command1.Click
   CLEAR MEMORY *!*退出前释放public申明过的变量
  thisform.release
 ENDPROC


ENDDEFINE
2023-09-02 23:44
tjdeming
Rank: 2
等 级:论坛游民
帖 子:429
专家分:54
注 册:2013-3-4
收藏
得分:0 
回复 8楼 sam_jiang
非常感谢你的耐心解答,我修正代码后能实现想要的了
2023-09-03 20:16
快速回复:表单方法事件2
数据加载中...
 
   



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

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