| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1257 人关注过本帖
标题:请教:下面是张洪举VFP9中的用类定义写的代码为什么不能运行?
取消只看楼主 加入收藏
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1547
专家分:184
注 册:2006-6-3
结帖率:79.38%
收藏
已结贴  问题点数:20 回复次数:3 
请教:下面是张洪举VFP9中的用类定义写的代码为什么不能运行?
附件
program3.rar (1.47 KB)



PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


    **************************************************
*-- Form:         form1 (d:\vfp8jc\基础篇\10\software\10.3.15\form6.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   01/29/04 05:14:10 PM
*
DEFINE CLASS form1 AS form


    Top = 0
    Left = 0
    Height = 231
    Width = 406
    DoCreate = .T.
    Caption = "单击列标头排序示例"
    Name = "form1"


    ADD OBJECT form1.grid1 AS grid WITH ;
        ColumnCount = 7, ;
        ChildOrder = "语文成绩", ;
        DeleteMark = .F., ;
        Height = 189, ;
        Left = 6, ;
        Panel = 1, ;
        RecordMark = .F., ;
        RecordSource = "tblstudent", ;
        SplitBar = .F., ;
        Top = 6, ;
        Width = 390, ;
        GridLineColor = RGB(128,128,128), ;
        LockColumns = 2, ;
        Name = "Grid1", ;
        Column1.ControlSource = "tblstudent.学号", ;
        Column1.Width = 59, ;
        Column1.Name = "Column1", ;
        Column2.ControlSource = "tblstudent.姓名", ;
        Column2.Width = 62, ;
        Column2.Name = "Column2", ;
        Column3.ControlSource = "tblstudent.学期", ;
        Column3.Width = 54, ;
        Column3.Name = "Column3", ;
        Column4.ControlSource = "tblstudent.语文成绩", ;
        Column4.Width = 71, ;
        Column4.Name = "Column4", ;
        Column5.ControlSource = "tblstudent.数学成绩", ;
        Column5.Width = 67, ;
        Column5.Name = "Column5", ;
        Column6.ControlSource = "tblstudent.英语成绩", ;
        Column6.Width = 90, ;
        Column6.Name = "Column6", ;
        Column7.ControlSource = "tblstudent.总成绩", ;
        Column7.Width = 90, ;
        Column7.Name = "Column7"


    ADD OBJECT form1.grid1.column1.header1 AS header WITH ;   **提示语法错误,以下只要是add object from1.grid1.column..... with 都提示语法错误
        Caption = "学号", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column2.header1 AS header WITH ;
        Caption = "姓名", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column2.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column3.header1 AS header WITH ;
        Caption = "学期", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column3.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column4.header1 AS header WITH ;
        Caption = "语文成绩", ;
        Picture = "up.bmp", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column4.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column5.header1 AS header WITH ;
        Caption = "数学成绩", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column5.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column6.header1 AS header WITH ;
        Caption = "英语成绩", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column6.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column7.header1 AS header WITH ;
        Caption = "总成绩", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column7.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 201, ;
        Left = 285, ;
        Height = 25, ;
        Width = 94, ;
        Caption = "关闭(\<C)", ;
        Name = "Command1"


    PROCEDURE header1.Click
        LOCAL lnRecno
        lnRecno=IIF(EOF() OR BOF(),1,RECNO())  &&保存当前记录号
        IF UPPER(JUSTSTEM(This.Picture))="UP"
            This.Picture="Down.bmp"
            SET ORDER TO 语文成绩 DESCENDING   &&降序排列
        ELSE
            This.Picture="Up.bmp"
            SET ORDER TO 语文成绩 ASCENDING    &&升序排列
        ENDIF

        Thisform.Refresh  
        GO lnRecno
    ENDPROC


    PROCEDURE command1.Click
        RELEASE Thisform
    ENDPROC


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


[ 本帖最后由 sylknb 于 2012-11-29 12:41 编辑 ]
搜索更多相关主题的帖子: PUBLIC software 基础 
2012-11-29 12:40
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1547
专家分:184
注 册:2006-6-3
收藏
得分:0 
我把下面14处的form1删除后,还是提示语法错误
ADD OBJECT grid1.column1.header1 AS header WITH ;  
        Caption = "学号", ;
        Name = "Header1"


    ADD OBJECT grid1.column1.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT grid1.column2.header1 AS header WITH ;
        Caption = "姓名", ;
        Name = "Header1"


    ADD OBJECT grid1.column2.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT grid1.column3.header1 AS header WITH ;
        Caption = "学期", ;
        Name = "Header1"


    ADD OBJECT grid1.column3.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT grid1.column4.header1 AS header WITH ;
        Caption = "语文成绩", ;
        Picture = "up.bmp", ;
        Name = "Header1"


    ADD OBJECT grid1.column4.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT grid1.column5.header1 AS header WITH ;
        Caption = "数学成绩", ;
        Name = "Header1"


    ADD OBJECT grid1.column5.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT grid1.column6.header1 AS header WITH ;
        Caption = "英语成绩", ;
        Name = "Header1"


    ADD OBJECT grid1.column6.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT grid1.column7.header1 AS header WITH ;
        Caption = "总成绩", ;
        Name = "Header1"


    ADD OBJECT grid1.column7.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"

2012-11-29 17:28
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1547
专家分:184
注 册:2006-6-3
收藏
得分:0 
附上原form6等内容
form6.rar (5.58 KB)


能不能用类游览器从已知的表单中提示代码并转为prg
我从form6表单中提取了代码
**************************************************
*-- Form:         form1 (d:\10.3.15\form6.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- 时间戳:   05/26/04 03:42:09 PM
*



PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

*---- 以上4句本人加上去的,下面都是从类游览器中提取form6.scx中的代码ADD OBJECT form1.grid1.column1.header1 AS header WITH 为什么提示语法错误

DEFINE CLASS form1 AS form


    Top = 10
    Left = 6
    Height = 231
    Width = 406
    DoCreate = .T.
    Caption = "单击列标头进行数据排序示例"
    Name = "Form1"


    ADD OBJECT grid1 AS grid WITH ;
        ColumnCount = 7, ;
        ChildOrder = "语文成绩", ;
        DeleteMark = .F., ;
        GridLines = 3, ;
        HeaderHeight = 19, ;
        Height = 189, ;
        Left = 6, ;
        Panel = 1, ;
        RecordMark = .F., ;
        RecordSource = "tblstudent", ;
        ScrollBars = 3, ;
        SplitBar = .F., ;
        Top = 6, ;
        Width = 390, ;
        GridLineColor = RGB(128,128,128), ;
        LockColumns = 0, ;
        AllowCellSelection = .T., ;
        Name = "Grid1", ;
        Column1.ControlSource = "tblstudent.学号", ;
        Column1.Width = 59, ;
        Column1.Name = "Column1", ;
        Column2.ControlSource = "tblstudent.姓名", ;
        Column2.Width = 62, ;
        Column2.Name = "Column2", ;
        Column3.ControlSource = "tblstudent.学期", ;
        Column3.Width = 54, ;
        Column3.Name = "Column3", ;
        Column4.ControlSource = "tblstudent.语文成绩", ;
        Column4.Width = 71, ;
        Column4.Name = "Column4", ;
        Column5.ControlSource = "tblstudent.数学成绩", ;
        Column5.Width = 67, ;
        Column5.Name = "Column5", ;
        Column6.ControlSource = "tblstudent.英语成绩", ;
        Column6.Width = 90, ;
        Column6.Name = "Column6", ;
        Column7.ControlSource = "tblstudent.总成绩", ;
        Column7.Width = 90, ;
        Column7.Name = "Column7"


    ADD OBJECT form1.grid1.column1.header1 AS header WITH ;
        Caption = "学号", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column2.header1 AS header WITH ;
        Caption = "姓名", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column2.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column3.header1 AS header WITH ;
        Caption = "学期", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column3.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column4.header1 AS header WITH ;
        Caption = "语文成绩", ;
        Picture = "up.bmp", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column4.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column5.header1 AS header WITH ;
        Caption = "数学成绩", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column5.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column6.header1 AS header WITH ;
        Caption = "英语成绩", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column6.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT form1.grid1.column7.header1 AS header WITH ;
        Caption = "总成绩", ;
        Name = "Header1"


    ADD OBJECT form1.grid1.column7.text1 AS textbox WITH ;
        BorderStyle = 0, ;
        Margin = 0, ;
        ForeColor = RGB(0,0,0), ;
        BackColor = RGB(255,255,255), ;
        Name = "Text1"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 201, ;
        Left = 285, ;
        Height = 25, ;
        Width = 94, ;
        Caption = "关闭(\<C)", ;
        Name = "Command1"


    PROCEDURE header1.Click
        LOCAL lnRecno
        lnRecno=IIF(EOF() OR BOF(),1,RECNO())  &&保存当前记录号
        IF UPPER(JUSTSTEM(This.Picture))="UP"
            This.Picture="Down.bmp"
            SET ORDER TO 语文成绩 DESCENDING   &&降序排列
        ELSE
            This.Picture="Up.bmp"
            SET ORDER TO 语文成绩 ASCENDING    &&升序排列
        ENDIF

        Thisform.Refresh  
        GO lnRecno
    ENDPROC


    PROCEDURE command1.Click
        RELEASE Thisform
    ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
2012-11-29 18:05
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1547
专家分:184
注 册:2006-6-3
收藏
得分:0 
谢谢各位了,可能我没有讲清楚,我的意思是有时书写类代码不是很熟练,先采用可视化的方法制作出一定要求的表单 然后再通过类游览器来看此表单类的代码是如何写的。
2012-12-02 10:29
快速回复:请教:下面是张洪举VFP9中的用类定义写的代码为什么不能运行?
数据加载中...
 
   



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

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