N Nitin Joshi Active Member Licensed User Longtime User Feb 22, 2025 #1 Hi, i am using following code however error message pops up when i run the program. Code: Copy For i= UDPRcvMsg.SubString2(28,31) To UDPRcvMsg.SubString2(31,34) Error message... For i= UDPRcvMsg.SubString2(28,31) To UDPRcvMs shell\src\b4i\example2\b4i_b4xmainpage_subs_0.java:570: error: > or ',' expected final int limit16 = BA.ObjectToNumber(__ref.getField(true,"_udprcvmsg" /*RemoteObject*/ ).runMethod(true,"SubString2::",(Object)(BA.numberCast(int.class, 31)),(Object)(BA.numberCast(int.class, 34))).<NSString*>get()).intValue;
Hi, i am using following code however error message pops up when i run the program. Code: Copy For i= UDPRcvMsg.SubString2(28,31) To UDPRcvMsg.SubString2(31,34) Error message... For i= UDPRcvMsg.SubString2(28,31) To UDPRcvMs shell\src\b4i\example2\b4i_b4xmainpage_subs_0.java:570: error: > or ',' expected final int limit16 = BA.ObjectToNumber(__ref.getField(true,"_udprcvmsg" /*RemoteObject*/ ).runMethod(true,"SubString2::",(Object)(BA.numberCast(int.class, 31)),(Object)(BA.numberCast(int.class, 34))).<NSString*>get()).intValue;
Solution BlueVision Feb 22, 2025 I have not tested your code. It could work under B4A because B4A may convert the strings automatically to integers. However, you should definitely see a warning: You are using a string as an integer, this may be a programming error.
I have not tested your code. It could work under B4A because B4A may convert the strings automatically to integers. However, you should definitely see a warning: You are using a string as an integer, this may be a programming error.
BlueVision Well-Known Member Licensed User Longtime User Feb 22, 2025 #2 I'm not using B4I, but you are using strings as variables for the for-next loop in this case. I think this is causing the error. Convert the substrings to integer variables before using them... You must also ensure that the substrings only contain digits. B4X: Copy Dim a = UDPRcvMsg.SubString2(28,31) as Int Dim b = UDPRcvMsg.SubString2(31,34) as Int For i = a To b Last edited: Feb 22, 2025 Upvote 0
I'm not using B4I, but you are using strings as variables for the for-next loop in this case. I think this is causing the error. Convert the substrings to integer variables before using them... You must also ensure that the substrings only contain digits. B4X: Copy Dim a = UDPRcvMsg.SubString2(28,31) as Int Dim b = UDPRcvMsg.SubString2(31,34) as Int For i = a To b
BlueVision Well-Known Member Licensed User Longtime User Feb 22, 2025 #3 I have not tested your code. It could work under B4A because B4A may convert the strings automatically to integers. However, you should definitely see a warning: You are using a string as an integer, this may be a programming error. Upvote 0 Solution
I have not tested your code. It could work under B4A because B4A may convert the strings automatically to integers. However, you should definitely see a warning: You are using a string as an integer, this may be a programming error.
N Nitin Joshi Active Member Licensed User Longtime User Feb 22, 2025 #4 Thanks dear. You are right. In For-Next loop string can not be considered as int. Meanwhile, i had to modify code as below... Code: Copy Dim k1,k2 As Int k1 = UDPRcvMsg.SubString2(28,31) k2 = UDPRcvMsg.SubString2(31,34) for i = k1 to k2 Upvote 0
Thanks dear. You are right. In For-Next loop string can not be considered as int. Meanwhile, i had to modify code as below... Code: Copy Dim k1,k2 As Int k1 = UDPRcvMsg.SubString2(28,31) k2 = UDPRcvMsg.SubString2(31,34) for i = k1 to k2