Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 by Thearon Willis, Bryan Newsome; ISBN: 9780764574016
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2007, 04:03 PM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with code: My.Computer.FileSystem

Im trying to make a little program that list all folders/subfolders in a directory that I specify in a TextBox, and I also want the program to show a messagebox If i write something wrong in the textbox like folders that not exits etc. but I cant get this to work.

This is my code so far:

Public Class Form1

    Private Sub btnListFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVisInnhold.Click
        'Create variabel
        Dim strFolder As String
        Dim strFolderName As String

        'Textbox for writing folder/station name
        strFolderName = TextBox1.Text

        'list all folders
        For Each strFolder In _
        My.Computer.FileSystem.GetDirectories(strFolderNam e)

            If My.Computer.FileSystem.DirectoryExists(strFolder) Then

                'Add the item to the list
                ListBox1.Items.Add(strFolder)

                'Tell the user
                MessageBox.Show("Found it, exiting the loop now.", "Info")
                'Quit the loop early

            Else
                MessageBox.Show("Folder/station does not exists.", "Error")

                Exit For

            End If

        Next

    End Sub

 
Old April 16th, 2007, 02:16 AM
Registered User
 
Join Date: Apr 2007
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default

hello!!
"Private Sub btnListFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVisInnhold.Click"

why is "btnListFolder_Click" different in "Handles btnVisInnhold.Click"? I think they should be the same?

 
Old April 23rd, 2007, 05:05 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Follow this link, http://msdn2.microsoft.com/en-us/vbasic/default.aspx, and there are two download links on the right hand of the page for "101 Code Samples for VB 2005" and "101 Code Samples for VB 2003" I belive that the later link has an example of what you are trying to accomplish. That sample should open and run in VB 2005 with little or no modifications necessary.

Thearon





Similar Threads
Thread Thread Starter Forum Replies Last Post
use My.Computer.FileSystem.ReadAllText in webdesin abc052107 Visual Studio 2005 4 July 5th, 2007 08:52 PM
Problem with code: My.Computer.FileSystem Sporty Visual Basic 2005 Basics 0 March 14th, 2007 03:52 PM
My.Computer.Filesystem run-time 424 error insidertrader Beginning VB 6 2 September 27th, 2006 02:43 PM
My.Computer problem sir_drinxalot BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 April 3rd, 2006 08:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.