Assigning values to array variables.

skcud

Member
Hey guys, I'm working on part of an app as a collab and have become quite stuck. I was hoping someone here could lend some help. Thanks for your time.

So basically, my app is just filling out forms. All the forms are the same so I just repeat the page. On the first page, the user specifies how many forms to fill out and this value is assigned to 'i'. I then set 'j' to 1 and increase it by one with every button click until 'j' is equal to 'i', which is when the app returns to the front page.

The point of the app is to accept values for 'y', 'b' and 'c'. The form I wrote has 3 input boxes, one for each of these variables. As it is up to the user to decide how many forms (or inputs) there are, I use this in globals:

B4X:
For y = 1 to i
Dim y(y) as double
etc. (Sorry for the crude format. This is not the computer on which I wrote the original code and I cannot copy and paste.)

When it comes to the form (which is a second module at this point), I coded the 'next' button to not only increase 'j' by 1, but also make main.y(main.j) = edittext1.text. I use y(main.j) because 'j' is always going to be equal to the page number I am currently on and I need the textboxes on that page to assign values to the 'y' of that page, so that they can be easily identified.

However, when I run the application, it freezes at the point where I try to equate main.y(main.j) to the edittext. It doesn't explain why, it just highlights that line of code in yellow and the app pauses.

I'm sorry if my explanations are lame, I will be back on my computer tomorrow and will be able to post the real code. But for now, if you know what I am talking about or are interested to help me, please let me know. Thank you.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Dim y(y) as double
Looks a little recursive. y should not be (y)

Dim y(x) as double
then try y = array as double(value1, value2, etc)

Might I recommend switching to a list?
Then you can use y.initialize2()
 

skcud

Member
Ah, I was trying to simplify my variable names to make it easier to follow. You're right, y(y) is messed up, sorry about that haha. I actually use YSpeed, BSpeed and CSpeed.

Would you be able to explain more about your list idea? I'm still very new to programming. Also, something that has been bugging me since day one is that I don't know how to target a user's selection in a list. Is this possible? In a way that listview can be used as a menu?

Thank you for helping.
 

mjcoon

Well-Known Member
Licensed User
Also, something that has been bugging me since day one is that I don't know how to target a user's selection in a list. Is this possible? In a way that listview can be used as a menu?

I'd like to help too, assuming we are talking about B4PPC (since that is this forum) and not B4A. But I don't really understand the intention. Is it possible to post a cut-down sample of what you have so far?

Mike.
 

skcud

Member
Ah, well it would appear I'm actually on the wrong damn forum. That sucks. I am in a rush as there is a deadline and didn't notice this was for a separate program. I can't find a help forum for B4a though. Is there a page similar to this for b4a users?
 
Top