Как мне описать массив в классе?
Мне нужно его использовать в методах, а описывать его как Public нельзя, ибо compilation Error -- arrays not allowed as Public members of object modules.
Dim arrProps(1 To 100) As String
Public Property Get TestProp(ByVal Index As Long) As String
TestProp = arrProp(Index)
End Property
Public Property Let TestProp(ByVal Index As Long, ByVal Value As String)
arrProp(Index) = Value
End Property
Option Explicit
Dim BigInteger(0 To 1000) As Long
Public Property Get a(ByVal Index As Long) As Long
a = BigInteger(Index)
End Property
Public Property Let a(ByVal Index As Long, ByVal Value As Long)
BigInteger(Index) = Value
End Property
Public Function Get_len() As Long
Get_len = a(0)
End Function
Public Sub Read(CurFile As Long)
Dim t, s As String
t = Input(1, #CurFile)
Do While (InStr("1234567890", t) = 0)
t = Input(1, #CurFile)
Loop
s = ""
Do While (InStr("1234567890", t) > 0)
s = s & t
If (EOF(CurFile)) Then Exit Do
t = Input(1, #CurFile)
Loop
a(0) = 0
Dim i As Long
For i = Len(s) To 1 Step -1
a(0) = a(0) + 1
a(a(0)) = CInt(Mid(s, i, 1))
Next i
End Sub
Public Function toString() As String
Dim i As Long
toString = ""
For i = a(0) To 1 Step -1
toString = toString & CStr(a(i))
Next i
End Function
Public Sub Add(b As BigInteger)
If (a(0) < b(0)) Then a(0) = b(0)
Dim i, r As Long
For i = 1 To a(0) Step 1
r = a(i) + b(i)
a(i) = r Mod 10
r = CInt(r / 10)
Next i
Do While (r > 0)
a(0) = a(0) + 1
a(a(0)) = r Mod 10
r = CInt(r / 10)
Loop
End Sub
Dim a As New BigInteger
Dim b As New BigInteger
Dim inFile, outFile As Long
inFile = FreeFile
Open App.Path & "\input.txt" For Input As #inFile
outFile = FreeFile
Open App.Path & "\output.txt" For Output As #outFile
a.Read (inFile)
b.Read (inFile)
a.Add (b)
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 135