Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
VBAでメソッドチェーンの例
Option Explicit
' クラスモジュール: CCalc
Private sum As Long
Private Sub Class_Initialize()
sum = 0
End Sub
Public Function plus(num As Long) As CCalc
sum = sum + num
Set plus = Me
End Function
Public Function minus(num As Long) As CCalc
sum = sum - num
Set minus = Me
End Function
Public Function show() As Long
show = sum
End Function
Option Explicit
' 標準モジュール: Module1
Sub test()
Dim calc As CCalc
Set calc = New CCalc
MsgBox calc.plus(10).minus(3).show ' 7
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.