I have a form (code below) which contains 2 text boxes.
The first text box displays the value stored in a variable named 'total_required'.
The second text box needs to display the variable declared 'chosen_type', this variable will store a chosen type from the
array, i.e. it needs to display either 'A' or 'B' or 'C' etc.
The way in which i need to determine the value of the 'chosen_type' variable is by choosing whichever types
value( the number associated with each letter, e.g A 105) can be divided into the 'total_required' value and
leave the [B]smallest remainder[/B]. However, if the remainder is greater than 50, then i need to add 1 to the number of
times that that the type value can be divided into total_required, and then find the 'new' remainder.
For example, with a total_required value of 2025:
Type A,105
Can be divided 19 times, remainder 30.
Type B,120
Can be divided 16 times, remainder 105 (as this is greater than 50 we add 1 to 16 and get 17*120=2040)
2040-2025=15, therefore remainder 15.
Type C, 152
Can be divided 13 times, remainder 49.
Type D, 101
Can be divided 20 times, remainder 5
Type E, 121
Can be divided 16 times, remainder 89(as 89>50, we add 1 to 16 and have 17*121=2057)
2057-2025=32, therefore remainder 32
Type C gives the smallest remainder(5) and so 'C' would be assigned to the variable 'chosen_type'.
I know how to get the remainder, through using Math.IEEERemainder, but i cannot get my head round a loop that
i would need to implement in order to do this.
Can anyone please help?
Public type_data As Object(,) = {{"A", 105}, _
{"B", 120}, _
{"C", 152}, _
{"D", 101}}
Public total_required As Single
Public chosen_type as string
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
total_required = 2025
Me.TextBox1.Text = total_required
Me.textBox2.text = chosen_type
End Sub