- This topic has 1 reply, 2 voices, and was last updated 15 years ago by String.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
April 6, 2009 at 10:40 pm #187368methodMember
Hi all . I try to use the following code to load playlist text file into listboxes . The code is from Admin musicbot(Music Bot Pal 8 or 9) .But unfortuenlty i get this error (but the listboxes get loaded with mp3 path and title)
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 ThenHowever, I get the above error if i only use the above code in my project but if i run loco full project i don’t get that error!!could you guys help me fix this error so i be able to load playlist data in to listboxes without any error? Looking forward for replies.Thanks
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
April 7, 2009 at 6:52 am #187369StringMemberOff hand, I’d say that your strArr is empty. Test to see is your array is populated.
-
AuthorPosts
Related
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.