Results 1 to 2 of 2

Thread: lost!

  1. #1

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    lost!

    Hey
    I am searching a dir for keywords and when it finds a file it adds it to a list box. here is the code
    VB Code:
    1. Dim TheDir As String = txtDir.Text
    2.         Dim di As New IO.DirectoryInfo(TheDir)
    3.         Dim diar1 As IO.FileInfo() = di.GetFiles()
    4.         Dim dra As IO.FileInfo
    5.    
    6.         For Each dra In diar1
    7.             Dim Filename As String = IO.Path.GetFileNameWithoutExtension(dra.FullName)
    8.             If dra.Extension = ".rtf" Or dra.Name.ToLower.IndexOf(txtSong.Text.ToLower) > -1 Then
    9.          
    10.                 results.Items.Add(dra)
    11.  
    12.             End If
    13.         Next


    that works and it adds them to a list box my problem it that i want to use the data in the listbox as a string and don't know how to convert it.

    if i try to go messagebox.show (results.SelectedItem) i get the error : Cast from type 'FileInfo' to type 'String' is not valid.

    If anyone knows how to conver the listbox to a sting that would be great thanks alot

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    results.SelectedItem.ToString

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width