Need help with this code ... Getting Error

b4AMarkO

Member
Licensed User
Longtime User
Error says Use of undeclared array : mymain
Occurred on line: 58
Dim myDes as String = myMain(0)
***********************************

B4X:
For i = 0 To Rows.Size - 1
         Dim myString As String
         myString = Rows.Get(i)
         If myString.Contains("[Description=") Then
          myString =  myString.Replace("[Description=", "")
         myString = myString.Replace("Location=", "")
           If myString.Contains(",") Then
              Dim myMain As List
             myMain = Regex.Split(",", myString)
             Dim myDes As String = myMain(0)
             Dim myLoc As String = myMain(1)
             lv1.AddSingleLine(myDes & " - " & myLoc)
             Log(myDes & " - " & myLoc)
           End If
            
         End If
Next

What I am trying to do and failing at is to split the string and place first part of string into
myDes
and Second part into
myLoc

I know Im missing something here or maybe this cant be done

:sign0085: :BangHead:
 

Geezer

Active Member
Licensed User
Longtime User
Your mymain variable seems to be a mixture of two types

You can either use it as a list using the code here
B4X:
Dim l As List
l.Initialize 
l.AddAll( Regex.split(" ", "The quick brown fox") )
For Z = 0 To l.Size - 1
    Log ( l.Get(Z) )
Next
or as a string array using this code
B4X:
Dim ls() As String = Regex.Split( " ", "One Two Three")
For Z = 0 To ls.Length - 1
    Log ( ls(Z) )
Next
 
Upvote 0

b4AMarkO

Member
Licensed User
Longtime User
Your mymain variable seems to be a mixture of two types

You can either use it as a list using the code here
B4X:
Dim l As List
l.Initialize 
l.AddAll( Regex.split(" ", "The quick brown fox") )
For Z = 0 To l.Size - 1
    Log ( l.Get(Z) )
Next
or as a string array using this code
B4X:
Dim ls() As String = Regex.Split( " ", "One Two Three")
For Z = 0 To ls.Length - 1
    Log ( ls(Z) )
Next

Thanx .... got it working
 
Upvote 0
Top