彰化一整天的論壇

 找回密碼
 立即註冊
查看: 869|回復: 1

宣告型別會影響執行結果

[複製鏈接]
發表於 2014-8-12 16:38:52 | 顯示全部樓層 |閱讀模式
  1. Sub test_sample()
  2.     Dim sFile As Variant

  3.     Dim oShell: Set oShell = CreateObject("Shell.Application")
  4.     Dim oDir:   Set oDir = oShell.Namespace("D:\tmh\word")
  5.    
  6.     For Each sFile In oDir.Items
  7.        Debug.Print oDir.GetDetailsOf(sFile, 0)
  8.     Next
  9. End Sub
  10. Sub test_error()
  11.     Dim sFile As Variant
  12.     Dim SFilePath As String
  13.     Dim oShell: Set oShell = CreateObject("Shell.Application")
  14.     SFilePath = "D:\tmh\word"
  15.     Dim oDir:   Set oDir = oShell.Namespace(SFilePath)
  16.    
  17.     For Each sFile In oDir.Items
  18.        Debug.Print oDir.GetDetailsOf(sFile, 0)
  19.     Next
  20. End Sub
  21. Sub test_ok()
  22.     Dim sFile As Variant
  23.     Dim SFilePath As Variant
  24.     Dim oShell: Set oShell = CreateObject("Shell.Application")
  25.     SFilePath = "D:\tmh\word"
  26.     Dim oDir:   Set oDir = oShell.Namespace(SFilePath)
  27.    
  28.     For Each sFile In oDir.Items
  29.        Debug.Print oDir.GetDetailsOf(sFile, 0)
  30.     Next
  31. End Sub
複製代碼


回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  

GMT+8, 2020-2-25 12:03 , Processed in 0.104155 second(s), 18 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表