Android Question Split string error

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
What's wrong with this code? I found it into the forum and I get an error:

B4X:
Public Sub getanno
Dim ResultScan as String
Dim strSplit() As String

ResultScan = "2017.PPP.1236.4"
strSplit = Regex.Split(".", ResultScan)

Log(strSplit(0))
End Sub

B4X:
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
    at it.android.imgspa.and_GestPFTerz.formscanner._getanno(formscanner.java:396)
    at it.android.imgspa.and_GestPFTerz.formscanner._scanbar_scanresult(formscanner.java:452)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
    at zxscanwrapper.zxScanWrapper$1.onCodeScanned(zxScanWrapper.java:204)
    at eu.livotov.labs.android.camview.ScannerLiveView.notifyBarcodeRead(ScannerLiveView.java:232)
    at eu.livotov.labs.android.camview.ScannerLiveView.onReceiveProcessedCameraFrame(ScannerLiveView.java:272)
    at eu.livotov.labs.android.camview.camera.AbstractController$ProcessingResultHandler.handleMessage(AbstractController.java:43)
    at android.os.Handler.dispatchMessage(Handler.java:110)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:5322)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
You saved my day for the second time.. Thanks! I used this one:

B4X:
Regex.Split("\.", ResultScan)
 
Upvote 0
Top