Daihao690 2014-09-19 04:07 采纳率: 0%
浏览 2351

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

这个该怎么写?

  • 写回答

1条回答 默认 最新

  • fonjames 2015-06-19 16:21
    关注

    都实现了property, 直接赋值跟获取就可以了。

    Realm.SetName=" 先天"
    Set Player.SetPlayerRealm = Realm

    参考MSDN的控件属性

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘