Android Tutorial How they do... #3

Informatix

Expert
Licensed User
Longtime User
For a value between 20 and 20000:
B4X:
 If spMode.SelectedIndex = 0 Then
                Dim FirstValue As Int = 20
                Dim LastValue As Int = 20000
                Dim Ratio As Float = (MaxAngle - MinAngle) / (LastValue - FirstValue)
                Activity.Title = Angle & "°  " & Round((Angle - MinAngle) / Ratio + FirstValue) & "/" & LastValue
Else
           ...
 

Mrjoey

Active Member
Licensed User
Longtime User
tnx man it worked well , anyway i would add a texteditor where the user put its own value.
now is there a way to reverse it , by meaning if i put a value between 20 to 20000 automaticly the knob sets the angle , tnx
 

Informatix

Expert
Licensed User
Longtime User
tnx man it worked well , anyway i would add a texteditor where the user put its own value.
now is there a way to reverse it , by meaning if i put a value between 20 to 20000 automaticly the knob sets the angle , tnx
It's simple maths. If I have:
MyValue = Round((Angle - MinAngle) / Ratio + FirstValue)
then I get:
Angle = (MyValue - FirstValue) * Ratio + MinAngle
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…