如何在Power Point应用程序中查找字典中的最大值?

问题描述 投票:0回答:1

以下代码在 Excel 中可以正常工作。

但我正在寻找 Power Point 解决方案。

如何在 Power Point 应用程序中查找字典中的最大值?

    Sub Macro1()
    
        Dim dict As Object
        Set dict = CreateObject("Scripting.Dictionary")
        
        For i = 1 To 10
            dict.Add Key:=i, Item:=i
        Next i
        
        For i = 0 To dict.Count - 1
           Debug.Print dict.Keys()(i), dict.Items()(i)
        Next i
        
        'The following two lines works properly in Excel. 
        'But I am looking for Power Point solution.
        Debug.Print Application.Max(dict.Items)
        Debug.Print WorksheetFunction.Max(dict.Items)
    
    End Sub
vba dictionary max powerpoint
1个回答
0
投票

这适用于 Powerpoint:

Sub Macro1()
    
        Dim dict As Object
        Set dict = CreateObject("Scripting.Dictionary")
        
        Dim i As Long
        For i = 1 To 10
            dict.Add Key:=i, Item:=i
        Next i
        
        Dim iMax As Long
        For i = 0 To dict.Count - 1
           Debug.Print dict.Keys()(i), dict.Items()(i)
           If dict.Items()(i) > iMax Then iMax = dict.Items()(i)
        Next i
        
        Debug.Print iMax
    End Sub

您必须检查循环内的最大值。

© www.soinside.com 2019 - 2024. All rights reserved.