标题:Visual Basic 6.0 精简版,如何在实体类中定义类属性?
取消只看楼主
代号690
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-9-19
结帖率:0
已结贴  问题点数:20 回复次数:0 
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-436299-1-1.html




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

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