iOS Question Picker help

Discussion in 'iOS Questions' started by rfresh, Jul 26, 2019.

  1. rfresh

    rfresh Well-Known Member Licensed 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?

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

    Erel Administrator Staff Member Licensed User

    You cannot add hidden values however you can use a Map that maps between the visible values and the hidden values.
    Code:
    Dim m As Map = CreateMap(0010076200120, ...)

    '
    Dim HiddenValue As Int = m.Get(Value)
     
  3. rfresh

    rfresh Well-Known Member Licensed User

    Thank you...
     
  4. emexes

    emexes Well-Known Member 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:
    Code:
    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, 111False))
    Next
    to interpolate the multiplier between the 100-pound steps given eg:
    Code:
    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: Jul 26, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice