読者です 読者をやめる 読者になる 読者になる

bekkou68の日記

開発しているサービス, IT技術, 英語など。

Array の要素をイミディエイトウィンドウに表示する - Show Array Elements to Immediate WIndow

VBA

実装 - Implementation

' ===== Outline
' Show elements of Array to immediate window.
'
' ===== Argument
' aryTarget: Array, you'd like to show elements.
'
' ===== Author
' bekkou68
Private Sub ShowArray(ByVal aryTarget As Variant)
    Dim varTarget As Variant
    Debug.Print "#Element: " & UBound(aryTarget) + 1
    For Each varTarget In aryTarget
        Debug.Print CStr(varTarget)
    Next
End Sub

テスト - Test

Option Explicit

Public Sub TestShowArray()
    Debug.Print "- - - - -"
    Call ShowArray(Array("apple", "banana", "niconico"))
    Debug.Print "- - - - -"
    Call ShowArray(Array(12, 34, 56))
    Debug.Print "- - - - -"
    Call ShowArray(Array())
    Debug.Print "- - - - -"
End Sub

' ===== Outline
' Show elements of Array to immediate window.
'
' ===== Argument
' aryTarget: Array, you'd like to show elements.
'
' ===== Author
' bekkou68
Private Sub ShowArray(ByVal aryTarget As Variant)
    Dim varTarget As Variant
    Debug.Print "#Element: " & UBound(aryTarget) + 1
    For Each varTarget In aryTarget
        Debug.Print CStr(varTarget)
    Next
End Sub


以下、イミディエイトウィンドウの出力。
The following is output of immediate window.

- - - - -
#Element: 3
apple
banana
niconico
- - - - -
#Element: 3
12
34
56
- - - - -
#Element: 0
- - - - -


うん、おk。
Now, good.


−ω−