Hello guys, im a bit stuck here as im not that good in programming and still learning :)
im stuck with an error "Index was outside the bounds of the array". i placed msgboxes so that i could really know how it is flowing, (i did'nt use the debug tool because i dont want it. :) )
anyhow the solutions i have made so far are:
1. i used
Option Explicit on
= didnt worked.
2. tried to lessen the ubound(arrayTextFile)
For i = 1 To UBound(ArrayTextFile) - 2
it ddnt work again
3. i used this kind of checking, i really dont know what it did. but it failed me :(
Dim placename As String
If ListView1.Items.Count > 0 Then
placename = ListView1.Items.Count = 0
Else
placename = String.Empty
End If
i know i am missing something i just cant see through codes,
so can anybody please help me. thank you guys.
here's the code for the function.
after i pass MsgBox("inside with - " & ListView1.Items.Count) Im directed aleady to the catch and posted with the message "Index was outside the bounds of the array"
Try
Dim ArrayTextFile() As String
Dim lineOfText As String
Dim i As Integer
lineOfText = rcvdata.ToString
ArrayTextFile = Split(lineOfText, "+CMGL", , CompareMethod.Text)
MsgBox("did i pass here?" & i)
MsgBox(UBound(ArrayTextFile))
For i = 1 To UBound(ArrayTextFile)
Dim input As String = ArrayTextFile(i)
Dim result() As String
Dim pattern As String = "(:)|(,"")|("","")"
MsgBox("did i pass here? -pattern")
result = Regex.Split(input, pattern)
Dim lvi As New ListViewItem
Dim concat() As String
MsgBox("did i pass here? -lvi and concat")
With (ListView1.Items.Add("null"))
MsgBox("inside with - " & ListView1.Items.Count)
.SubItems.AddRange(New String() {result(2)})
MsgBox("did i pass here? result 2")
.SubItems.AddRange(New String() {result(4)})
MsgBox("did i pass here? -result 4")
Dim myString, position As String
myString = result(6)
position = myString.Length - 2
myString = myString.Remove(position, 2)
.SubItems.Add(myString)
MsgBox("did i pass here? -result5")
concat = New String() {result(8) & result(9) & result(10) & result(11) & result(12).Substring(0, 2)}
.SubItems.AddRange(concat)
Dim lineOfTexts As String
Dim arrayTextFiles() As String
lineOfTexts = ArrayTextFile(i)
arrayTextFiles = Split(lineOfTexts, "+32", , CompareMethod.Text)
.SubItems.Add(arrayTextFiles(i))
End With
MsgBox("did i pass here? going to the top to loop again")
Next
MsgBox("loop finish")
Catch ex As Exception
MsgBox("what is wrong?" & ex.Message)
End Try
End Sub