| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 454 人关注过本帖
标题:Visual Basic 6.0 精简版,如何在实体类中定义类属性?
只看楼主 加入收藏
代号690
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-9-19
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
Visual Basic 6.0 精简版,如何在实体类中定义类属性?
我想在类中定义类属性

玩家类代码

'玩家类
'名称
Private Name As String
'性别
Private Sex As SexEnum
'级别
Private Level As Integer
'当前级别分数
Private LevelScore As Integer
'总分
Private SumScore As Integer
'境界
Private PlayerRealm As Realm
'豆豆虫
Private PlayerPeasBug As PeasBug

'属性Get和Set方法
Public Property Get GetName() As String
GetName = Name
End Property
Public Property Let SetName(SetName As String)
Name = SetName
End Property
Public Property Get GetSex() As SexEnum
GetSex = Sex
End Property
Public Property Let SetSex(SetSex As SexEnum)
Sex = SetSex
End Property
Public Property Get GetPlayerRealm() As Realm
GetPlayerRealm = PlayerRealm
End Property
Public Property Let SetPlayerRealm(ByVal SetPlayerRealm As Realm)
PlayerRealm = SetPlayerRealm
End Property

境界类代码
'境界类名称为Realm
'境界名称
Private Name As String
'进入下一境界所需分数
Private NextRealmScore As Integer

'属性Get和Set方法
Public Property Get GetName() As String
GetName = Name
End Property
Public Property Let SetName(SetName As String)
Name = SetName
End Property
Public Property Get GetNextRealmScore() As Integer
GetNextRealmScore = NextRealmScore
End Property
Public Property Let SetNextRealmScore(SetNextRealmScore As Integer)
NextRealmScore = SetNextRealmScore
End Property

我这样写报错

Set Realm = New Realm
Realm.SetName() = "先天"
Player.SetPlayerRealm() = Realm
我想问的是

 '境界
Private PlayerRealm As Realm

Public Property Get GetPlayerRealm() As Realm
    GetPlayerRealm = PlayerRealm
End Property
Public Property Let SetPlayerRealm(ByVal SetPlayerRealm As Realm)
    PlayerRealm = SetPlayerRealm
End Property

这个该怎么写?
Private PlayerRealm As 什么类型
或者怎么实现在类中定义类属性?
谢谢
搜索更多相关主题的帖子: 如何 豆豆 精简版 
2014-09-19 15:13
砖家的谎言
Rank: 12Rank: 12Rank: 12
等 级:禁止访问
威 望:30
帖 子:693
专家分:3898
注 册:2013-12-6
收藏
得分:7 
顶贴

我不是砖家,要努力成为砖家。
2014-09-20 08:37
益西翁登
Rank: 4
等 级:业余侠客
威 望:1
帖 子:126
专家分:272
注 册:2010-2-22
收藏
得分:7 
哈哈,顶贴
2014-09-20 17:22
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4941
专家分:30047
注 册:2008-10-15
收藏
得分:7 
Realm.SetName() = "先天"
Player.SetPlayerRealm() = Realm

看你是属性还是方法,
属性 前面不能有 括号,方法使用调用 call Realm.SetName("先天")

具体,你自己测试一下。

对类这块也不是很熟。

授人于鱼,不如授人于渔
早已停用QQ了
2014-09-20 18:14
快速回复:Visual Basic 6.0 精简版,如何在实体类中定义类属性?
数据加载中...
 
   



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

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