⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 harddisk.cls

📁 简单的操作系统程序
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "HardDisk"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
Dim Data(0 To 8191) As Byte
'local variable(s) to hold property value(s)
Private mvarDataOnLine As Byte 'local copy
Private mvarIOAddress As Integer 'local copy
'local variable(s) to hold property value(s)
'Private mvarID As Integer 'local copy
'Public Property Let ID(ByVal vData As Integer)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.ID = 5
'    mvarID = vData
'End Property


Public Property Get ID() As Long
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.ID
    ID = 8192
End Property




Public Function ReadData(Optional ByVal IOAddress As Integer) As Byte
    If IOAddress > -1 And IOAddress < 8192 Then
        If Not IsMissing(IOAddress) Then
            mvarIOAddress = IOAddress
        End If
        mvarDataOnLine = Data(mvarIOAddress)
        ReadData = mvarDataOnLine
    Else
        ReadData = 0
    End If
End Function

Public Function WriteData(Optional ByVal IOAddress As Integer, Optional ByVal Datas As Byte) As Boolean
    WriteData = False
    If IOAddress > -1 And IOAddress < 8192 Then
        If Not IsMissing(IOAddress) Then
            mvarIOAddress = IOAddress
        End If
        If Not IsMissing(Datas) Then
            mvarDataOnLine = Datas
        End If
        Data(mvarIOAddress) = mvarDataOnLine
        WriteData = True
    End If
End Function

'**********************************************************************
'以下是这个类的构造函数和析构函数
'**********************************************************************
Private Sub Class_Initialize()
    Open "HardDisk.dat" For Binary Access Read Write As #1
    Dim I As Integer
    For I = 0 To 8191
        Get #1, I + 1, Data(I)
    Next I
End Sub
Private Sub Class_Terminate()
    Dim I As Integer
    For I = 0 To 8191
        Put #1, I + 1, Data(I)
    Next I
    Close #1
End Sub


Public Property Let IOAddress(ByVal vData As Integer)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.IOAddress = 5
    If IOAddress > -1 And IOAddress < 8192 Then
        mvarIOAddress = vData
    End If
End Property


Public Property Get IOAddress() As Integer
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.IOAddress
    IOAddress = mvarIOAddress
End Property



Public Property Let DataOnLine(ByVal vData As Byte)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.DataOnline = 5
    mvarDataOnLine = vData
End Property


Public Property Get DataOnLine() As Byte
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.DataOnline
    DataOnLine = mvarDataOnLine
End Property



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -