iOS Question for next with step -1 problem

tufanv

Expert
Licensed User
Hello

I have a strange problem with for next step -1
Code:

Dim n As Int =0

For i=listcevap.Size-1 To (listcevap.Size-TextField1.Text.Length) Step -1

If listcevap.Get(i) = TextField1.Text.CharAt(n) Then
listsonuc.Add("1")
Else
'Exit
End If

next

Now listcevap.size is 12. and textfield1.text.length is 4
so for next is between i=11 to 8 step -1

but during wathcing the logs i see that b4i first gets i=8 than 9 than 10 than 11 instead of first 11 than 10 than 9 than 8 (while geting the values of list )

What am i doing wrong ? I am about to go mad about this.
 

tufanv

Expert
Licensed User
I tried to create a small project it works perfect on it but in my real project it works as i wrote previously. Interesting, I cant find the problem
 
Upvote 0

klaus

Expert
Licensed User
Add a breakpoint just before the For loop and go through the code step by step.
You may also put Logs showing the values of listcevap.Size and TextField1.Text.Length.
 
Upvote 0

tufanv

Expert
Licensed User
Yes i found the problem. Now the problem is for example textfield1.text.charat(1) = 3
and listcevap.get(i) = 4
i cant get the sum this two numbers it says "Error description: Cannot cast: {Type=Char,Rank=0, RemoteObject=True} to number."
i think b4i sees one as number one as charachter. How can i make it see both of them as numbers so i can get the sum for example ?
 
Upvote 0

tufanv

Expert
Licensed User
Dim y= textfield1.Text.CharAt(n) As Int gives the same error : "Error description: Cannot cast: {Type=Char,Rank=0, RemoteObject=True} to number."
 
Upvote 0

tufanv

Expert
Licensed User
fixed the problem by :

dim y as char = listcevap.get(i)

so i compare two chars and if they are same it is enough for me. Thanks for all help
 
Upvote 0
Top