W Whack New Member Jan 26, 2014 #1 Hello, I have an array called strPackets() which is a string, and I'm using regex.split to fill the array with different sections of another string (strBuffer) which are separated by Chr(4) Code: Copy strPackets = Regex.Split(Chr(4), strBuffer) However, after I do this and I try to get the length of an array value, like this, it errors. Code: Copy If strPackets(anyvalidnumberinthearray).Length > 3 Then What am I doing wrong? I can't get anything from that value but it definitely exists because the regex.split fills strPackets(1) with a string Thanks in advance
Hello, I have an array called strPackets() which is a string, and I'm using regex.split to fill the array with different sections of another string (strBuffer) which are separated by Chr(4) Code: Copy strPackets = Regex.Split(Chr(4), strBuffer) However, after I do this and I try to get the length of an array value, like this, it errors. Code: Copy If strPackets(anyvalidnumberinthearray).Length > 3 Then What am I doing wrong? I can't get anything from that value but it definitely exists because the regex.split fills strPackets(1) with a string Thanks in advance
Erel B4X founder Staff member Licensed User Longtime User Jan 27, 2014 #2 It should be: Code: Copy If strPackets.Length > 3 Then Upvote 0
S sorex Expert Licensed User Longtime User Jan 27, 2014 #3 you need to define the array that regex will split to Code: Copy Dim strPackets() As String strPackets= Regex.Split(Chr(4), "lklklk lk " & Chr(4) & "lk lk lk" ) Log(strPackets(0).Length) If strPackets(0).Length > 3 Then Log("ok") Else Log("not ok") End If that put this in the log Code: Copy ** Activity (main) Create, isFirst = true ** 10 ok ** Activity (main) Resume ** Upvote 0
you need to define the array that regex will split to Code: Copy Dim strPackets() As String strPackets= Regex.Split(Chr(4), "lklklk lk " & Chr(4) & "lk lk lk" ) Log(strPackets(0).Length) If strPackets(0).Length > 3 Then Log("ok") Else Log("not ok") End If that put this in the log Code: Copy ** Activity (main) Create, isFirst = true ** 10 ok ** Activity (main) Resume **