Click here to Skip to main content
15,892,005 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionNeed help with a project, I am really stumped! Pin
Ogre72228-May-08 20:04
Ogre72228-May-08 20:04 
AnswerRe: Need help with a project, I am really stumped! Pin
Eduard Keilholz28-May-08 20:42
Eduard Keilholz28-May-08 20:42 
GeneralRe: Need help with a project, I am really stumped! Pin
Ogre72229-May-08 2:44
Ogre72229-May-08 2:44 
AnswerRe: Need help with a project, I am really stumped! Pin
Sam Xavier28-May-08 23:26
Sam Xavier28-May-08 23:26 
GeneralRe: Need help with a project, I am really stumped! Pin
Ogre72229-May-08 2:41
Ogre72229-May-08 2:41 
GeneralRe: Need help with a project, I am really stumped! Pin
Chinners29-May-08 3:14
Chinners29-May-08 3:14 
GeneralRe: Need help with a project, I am really stumped! Pin
Ogre72229-May-08 4:26
Ogre72229-May-08 4:26 
GeneralRe: Need help with a project, I am really stumped! Pin
Chinners29-May-08 4:57
Chinners29-May-08 4:57 
Hi,

No problem. It is really a simple class, but very useful in this instance (assuming you are displaying the list of files in a listbox, and using vb.net!!!).

If you are still struggling, here is a bit of messy code that may show you a bit more. All you need to do is create a new form with one listbox called listbox1, and paste this code into your app.

Public Class MyFileNameClass
   Public FileName As String
   Public Overrides Function ToString() As String
      Return System.IO.Path.GetFileName(FileName)
   End Function
End Class

Private Sub AddItemsToListBox(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
   Me.ListBox1.Items.Clear()
   For Each FileNameStr As String In IO.Directory.GetFiles("c:\")
      Dim o As New MyFileNameClass
      o.FileName = FileNameStr
      Me.ListBox1.Items.Add(o)
   Next
End Sub

Public Sub DisplayInfo(ByVal sender As Object, ByVal e As EventArgs) Handles ListBox1.Click
   If ListBox1.SelectedIndices.Count > 0 Then
      For Each i As Integer In ListBox1.SelectedIndices
         Dim o As Object = ListBox1.Items(i)
         If TypeOf o Is MyFileNameClass Then
            MessageBox.Show(DirectCast(o, MyFileNameClass).FileName)
         End If
      Next
   End If
End Sub

This code should populate the listbox with all the files in your c:\ folder, but only display the name. When you click on a file, a messagebox will pop up with the full path & filename. Nothing exciting, but I think it may get you closer to what you want to do.
GeneralRe: Need help with a project, I am really stumped! Pin
Ogre72229-May-08 5:22
Ogre72229-May-08 5:22 
GeneralRe: Need help with a project, I am really stumped! Pin
Ogre72229-May-08 15:47
Ogre72229-May-08 15:47 
GeneralRe: Need help with a project, I am really stumped! Pin
Chinners29-May-08 22:35
Chinners29-May-08 22:35 
GeneralRe: Need help with a project, I am really stumped! Pin
Steven J Jowett29-May-08 4:07
Steven J Jowett29-May-08 4:07 
QuestionCheck tinytext column in MySQL Database with VB.NET Pin
drexler_kk28-May-08 15:17
drexler_kk28-May-08 15:17 
AnswerRe: Check tinytext column in MySQL Database with VB.NET Pin
jzonthemtn29-May-08 2:36
jzonthemtn29-May-08 2:36 
QuestionTrouble with VB.NET and XPath Pin
Dominick Marciano28-May-08 9:45
professionalDominick Marciano28-May-08 9:45 
AnswerRe: Trouble with VB.NET and XPath Pin
MidwestLimey28-May-08 13:26
professionalMidwestLimey28-May-08 13:26 
GeneralRe: Trouble with VB.NET and XPath Pin
Dominick Marciano29-May-08 6:43
professionalDominick Marciano29-May-08 6:43 
GeneralRe: Trouble with VB.NET and XPath Pin
MidwestLimey29-May-08 8:19
professionalMidwestLimey29-May-08 8:19 
QuestionbackgroundWorker Help Pin
Cory Kimble28-May-08 7:35
Cory Kimble28-May-08 7:35 
AnswerRe: backgroundWorker Help Pin
Kschuler28-May-08 8:30
Kschuler28-May-08 8:30 
GeneralRe: backgroundWorker Help Pin
Cory Kimble28-May-08 10:47
Cory Kimble28-May-08 10:47 
GeneralRe: backgroundWorker Help Pin
Kschuler28-May-08 10:57
Kschuler28-May-08 10:57 
AnswerRe: backgroundWorker Help Pin
Chinners28-May-08 23:05
Chinners28-May-08 23:05 
QuestionGraphics question Pin
sa_runner28-May-08 5:27
sa_runner28-May-08 5:27 
AnswerRe: Graphics question Pin
Chinners28-May-08 5:57
Chinners28-May-08 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.