Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics 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, 03:52 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






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 BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 2 April 23rd, 2007 05:05 AM
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.