0
Set fso=CreateObject("Scripting.FileSystemObject")
DesktopPath=CreateObject("WScript.Shell").SpecialFolders("Desktop")
'Files count
msgbox "the no of files on the desktop is:"
&fso.GetFolder(DesktopPath).Files.count
'Folders count
msgbox "the no of folder on the desktop is:"
&fso.GetFolder(DesktopPath).SubFolders.count

the above mentioned code is displaying the following error

Hackoo
  • 18,337
  • 3
  • 40
  • 70
vadiraj
  • 11
  • 1

1 Answers1

0

You should add _ at the end of the comment of your MsgBox for break a line :

Set fso=CreateObject("Scripting.FileSystemObject")
DesktopPath=CreateObject("WScript.Shell").SpecialFolders("Desktop")
'Files count
msgbox "The N° of files on the desktop is : "_
& fso.GetFolder(DesktopPath).Files.count
'Folders count
msgbox "The N° of folder on the desktop is : "_
& fso.GetFolder(DesktopPath).SubFolders.count
Hackoo
  • 18,337
  • 3
  • 40
  • 70
  • Thank you that worked very well – vadiraj Nov 15 '21 at 19:09
  • It's been covered many times as you will be well aware @hackoo. – user692942 Nov 15 '21 at 19:16
  • @vadiraj Please take Stack Overflow (SO) [tour](https://stackoverflow.com/tour) to learn how to say thanks on SO by accepting an answer on being helpful by clicking on gray check mark symbol left to an answer. See also [How does accepting an answer work?](https://meta.stackexchange.com/questions/5234/) A question with no accepted answer is rated as a not answered question even if there are good answers. – Hackoo Nov 16 '21 at 06:16
  • 1
    @Hackoo Please read the Stack Overflow (SO) [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) to learn when to and not to answer a question (especially "Answer well-asked questions" section). – user692942 Nov 16 '21 at 12:59