iOS Question Picker help

rfresh

Well-Known Member
Licensed User
Longtime User
I'm wondering if the Picker component will allow me to pull another value from the visible value that I have selected?

For my project, I need to select a fuel quantity, such as 300 pounds. I then need to take that value and multiply it by another, unique value for 300. Below I populate the Picker with an array of values. I see these values when I show the Picker and the value I pick is the value I then use and it's the one that I see.

I am wondering if I can include a kind of 'hidden' value for each array item and when I select, return that non-visible value?

Does the picker allow me to use it that way?

I'd like to set up the array something like this:

0,0
100,76
200,120
300,223
400,385

and then when I select 300, be able to fetch the 223 value?

B4X:
    fuelWeights.Initialize2(Array As String("0", _
    "100", _
    "200", _
    "300", _
    "400", _
    "500"))
    PickerFuel.SetItems(0,fuelWeights)
    PickerFuel.SelectRow(0,0,False)
 

emexes

Expert
Licensed User
edit: it occurred to me later that perhaps those points were derived from an existing function or table, in which case: you should continue using that


Erel's way is simple and works great, but if you are using fuel quantities other than the five listed, and you promise not to use it for fuel quantities outside the 0..400 pound range, then you could also use this:
B4X:
For FuelPounds = 0 To 400 Step 50
    Dim FuelMultiplier As Float = -3.79167E-08 * Power(FuelPounds, 4) + 3.79167E-05 * Power(FuelPounds, 3) - 1.03208E-02 * Power(FuelPounds, 2) + 1.45083 * FuelPounds
    Log(FuelPounds & " " & NumberFormat2(FuelMultiplier, 1, 1, 1, False))
Next
to interpolate the multiplier between the 100-pound steps given eg:
B4X:
0 0.0
50 51.2
100 76.0
150 94.2
200 120.0
250 162.0
300 223.0
350 300.2
400 385.0
 
Last edited:
Upvote 0
Top