Results 1 to 10 of 10

Thread: [serious] My first VB.Net App!

Threaded View

  1. #1

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    [serious] My first VB.Net App!

    It just took me 20minutes to write my first VB.Net App (.Net FW 2)
    There is no error handling or anything, but, it works!
    Any tips in error handling? Or even how to do it...

    Simply it strips Extended info and wma files from a winamp playlist.

    VB Code:
    1. Imports System.IO
    2. Public Class Form1
    3.  
    4.     Private Sub CMDOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDOpenFile.Click
    5.         Dim FileName As String
    6.         CDopen.Filter = "M3U Playlist|*.m3u|All Files|*.*"
    7.         CDopen.ShowDialog()
    8.         FileName = CDopen.FileName.ToString
    9.         Dim s As String
    10.         If FileName <> "" Then
    11.             Dim sr As New StreamReader(FileName)
    12.             While sr.Peek <> -1
    13.                 s = sr.ReadLine.ToString
    14.                 List1.Items.Add(s)
    15.             End While
    16.             sr.Close()
    17.         End If
    18.         Label1.Text = "Line Count: " & List1.Items.Count()
    19.     End Sub
    20.  
    21.     Private Sub CMDparse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDparse.Click
    22.         Dim i As Long
    23.         For i = List1.Items.Count() - 1 To 0 Step -1
    24.             Me.List1.SelectedIndex = i
    25.             If List1.Text.StartsWith("#EXT") Or List1.Text.EndsWith(".wma") Then
    26.                 List1.Items.Remove(List1.Text)
    27.             End If
    28.             Label1.Text = "Line Count: " & List1.Items.Count()
    29.         Next
    30.     End Sub
    31.  
    32.     Private Sub CMDsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMDsave.Click
    33.         Dim i As Integer
    34.         Dim FileName As String
    35.         Dim sw As StreamWriter
    36.         CDsave.Filter = "M3U Playlist|*.m3u|All Files|*.*"
    37.         CDsave.ShowDialog()
    38.         FileName = CDsave.FileName
    39.         If FileName <> "" Then
    40.             sw = New StreamWriter(FileName)
    41.             For i = 0 To List1.Items.Count - 1
    42.                 sw.WriteLine(List1.Items.Item(i))
    43.             Next
    44.             sw.Close()
    45.         End If
    46.     End Sub
    47. End Class
    Last edited by thegreatone; Jun 11th, 2006 at 01:01 AM.
    Zeegnahtuer?

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