Hi all . I try to use the following code to load playlist text file into listboxes . But unfortuenlty i get this error (but the listboxes get loaded with mp3 path and title):
pointing at the following line:
'Check for unwanted vbCrLf (which would yeild a "")
If Len(strArr(intLB)) <> 0 Then
could you guys help me fix this error so i be able to load playlist data in to listboxes without any error? My project has 2 listbox and one load button.
Looking forward for replies.Thanks
Run-time error 9
subscript out of range
pointing at the following line:
'Check for unwanted vbCrLf (which would yeild a "")
If Len(strArr(intLB)) <> 0 Then
could you guys help me fix this error so i be able to load playlist data in to listboxes without any error? My project has 2 listbox and one load button.
Looking forward for replies.Thanks
Code:
Private Sub Command1_Click()
'If Label1.Caption = "Not Connected" Then
'MsgBox "You must Connect to Room", vbCritical, "Not Connected"
'Else
Dim i As Long
Dim intLB As Long 'Is an index counter
Dim lngCtr As Long 'Represents the count of individual lines of data
Dim strOpenPathFile As String, strArr() As String, strBuffArr() As String
With CommonDialog1
.CancelError = True
On Error GoTo CommDiaCancelled
.Filter = "Text Files (*.txt)|*.txt|Word Doc (*.doc)|*.doc"
.ShowOpen
End With
strOpenPathFile = CommonDialog1.FileName
Open strOpenPathFile For Input As #1
strArr = Split(Input(LOF(1), 1), vbCrLf)
Close #1
'Clear all the ListBoxs
List1.Clear
List2.Clear
lngCtr = UBound(strArr)
For intLB = 0 To lngCtr
CommDiaCancelled:
If Err.Number = 32755 Then
MsgBox "Cancel selected !"
Exit Sub
End If
'Check for unwanted vbCrLf (which would yeild a "")
If Len(strArr(intLB)) <> 0 Then
'Split the Line of data
strBuffArr = Split(strArr(intLB), vbTab)
'Load the data into the ListBoxs
List1.AddItem strBuffArr(0)
List2.AddItem strBuffArr(1)
End If
Next
Call Number(List1, " - ")
List1.Selected(0) = True
For i = List1.ListCount - 1 To 0 Step -1 ' counts list entries
If List1.Selected(i) = True Then ' if selected then
Text1.Text = List1.List(i) ' add to other list
Text2.Text = List2.List(i)
Text3.Text = List1.List(i)
Text3.Text = Replace(Text3.Text, ".mp3", "")
Text3.Text = Replace(Text3.Text, ".avi", "")
Text3.Text = Replace(Text3.Text, ".asf", "")
Text3.Text = Replace(Text3.Text, ".mpeg", "")
Text3.Text = Replace(Text3.Text, ".mpg", "")
Text3.Text = Replace(Text3.Text, ".wav", "")
Text3.Text = Replace(Text3.Text, ".wmv", "")
Text3.Text = Replace(Text3.Text, ".wma", "")
Text3.Text = Replace(Text3.Text, ".cda", "")
Text3.Text = Replace(Text3.Text, ".mid", "")
Text3.Text = Replace(Text3.Text, ".midi", "")
Text3.Text = Replace(Text3.Text, ".rm", "")
RichTextBox3.TextRTF = Replace(RichTextBox1.TextRTF, "%song", Text3)
If Option2.Value = True Then
Else
'Call RoomSend(RichTextBox3.TextRTF)
End If
End If
Next
'If Option1.Value = True Then
'wmp.URL = Text2.Text
'Timer1.Enabled = True
'Else
'MsgBox "You must press play then click on start buttom for the program to start", vbInformation, "Autoplay Off"
'End If
'End If
'Text10.Text = List1.ListCount
End Sub