Welcome to Dream.In.Code
Become a VB Expert!

Join 149,487 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,327 people online right now. Registration is fast and FREE... Join Now!




Checking for subfolders and listing them ****REVISED**** PLEASE CHECK

 
Reply to this topicStart new topic

Checking for subfolders and listing them ****REVISED**** PLEASE CHECK, please help. im lost!

crystal_lynn
27 Apr, 2007 - 12:59 PM
Post #1

New D.I.C Head
*

Joined: 27 Apr, 2007
Posts: 3


My Contributions
This is my 346th attempt (or atleast it feels that way). I read the book, browsed through windows script technologies HELP system.

Here is what my program is SUPPOSE to do.
-check for parameter ( only one, else leave error msg). end
-check to see if that drive (parameter entered by user) exists else error msg, end
-check to see if that drive is ready else error msg, end
-check for subfolders on the root of that drive if non exist error msg, end
-if there are subfolders, display them (no more than 20 per msgbox),
-use inputbox to get user's choice of folder
-check to see if files exist in that folder, if exist - show list of files, else error message, end




CODE

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~ Assignment45.vbs ~
'
'Crystal T
'April 27th, 2007
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Option Explicit

'Declare Variables

Dim args, mydrive, fsoobject, disk, check
Dim folder, subfold, f, fl, fc, s


Const ErrorBar="Error!"

' Make sure the user entered only ONE parameter and assign that to the variable name "drive"

Set args=Wscript.arguments
If args.count<>1 Then
    MsgBox "You can only enter one, and only ONE drive letter!.", 48 , ErrorBar
    Else
    mydrive=args.item(0)
    End If

'Check for Drive existance

Set fsoobject=WScript.CreateObject("Scripting.FileSystemObject")
Set disk=fsoobject.getdrive (mydrive)

If fsoobject.DriveExists(disk) Then
    MsgBox "Drive " & disk & " does exist!", vbOKOnly , "The Drive Exists!"
        Else
        MsgBox "The drive does not exist!", 48, ErrorBar
End If

'Check to see if Drive is ready

If disk.IsReady Then
    MsgBox "Drive " & disk & " is ready!", vbOKOnly, "Its ready!"
        Else
        MsgBox "The Drive is NOT ready!", 48, ErrorBar
End If

'Check for existance of subfolders and list them

Set folder=fsoobject.GetFolder(disk.RootFolder)

If fsoobject.FolderExists(subfold) Then
    MsgBox "There are subfolders!", 48, ErrorBar
End If

Set subfold=fsoobject.GetFolder(folder.SubFolders)
If fsoobject.FolderExists(subfold) Then
    MsgBox "That folder exists! Here comes the list of files for that folder"
End If



'Get subfolder name from user
check=InputBox("Please enter the name of the subfolder's files you'd like to see")
If fsoobject.FolderExists(check) Then
   Set f = fsoobject.GetFolder(check)
   Set fc = f.Files
   For Each f1 in fc
      s = s & f1.name
      s = s &   "<BR>"
   Next
   ShowFileList = s
   Then
   MsgBox showfilelist
       Else
       MsgBox ("There's no files in that folder! Bye!"), vbOKOnly, ErrorBar
End If
    
    


This post has been edited by crystal_lynn: 27 Apr, 2007 - 07:14 PM
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Checking For Subfolders And Listing Them ****REVISED**** PLEASE CHECK
28 Apr, 2007 - 11:18 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,349



Thanked: 51 times
Dream Kudos: 25
My Contributions
Are you receiving any errors? If so, can you specify? If not, are you experiencing undesired brhaviour? If so, can you provide a description?
User is online!Profile CardPM
+Quote Post

crystal_lynn
RE: Checking For Subfolders And Listing Them ****REVISED**** PLEASE CHECK
30 Apr, 2007 - 08:22 AM
Post #3

New D.I.C Head
*

Joined: 27 Apr, 2007
Posts: 3


My Contributions
QUOTE(Amadeus @ 28 Apr, 2007 - 12:18 PM) *

Are you receiving any errors? If so, can you specify? If not, are you experiencing undesired brhaviour? If so, can you provide a description?



This is my error.

E:\Scripting\assignment45.vbs(71, 4) Microsoft VBScript compilation error: Expected statement

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 04:58PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month