Reputation: 53
Hi I am a first year student at College studying Programming. I am struggling to write the code for a calculation. The calculation I wish to do is to multiply the quantity of an item by the price. The problem is that the "form" i am creating uses a letter (i.e A, B, C etc) which corresponds to a set value. I do not know how to link the Letter to the corresponding value. For Example, A= 25, B= 20, C=25 I want to calculate the total of 6 lots of A. I am also using a Combo Box to list the Letters. Thanks in advance
Upvotes: 1
Views: 661
Reputation: 415600
There are a lot of ways you could do this. A Select statement is one option. If/Else is another. A Dictionary(Of String, Decimal) is a third option. Since this is homework, you've probably covered one of those in class recently, and that's the answer you should pursue.
Upvotes: 0
Reputation: 6846
I haven't used VB in years, but this is a pretty classic problem. You just need an array with 26 entries, one for each letter, with each entry in the array initialized to the appropriate value for that letter. Then when the user has chosen a letter, use the index of the selected item in the combo box to index into your array. For example, value = array[selectedItemIndex]
Upvotes: 1