VB.net: How to add different multipliers together?

青春壹個敷衍的年華 提交于 2019-12-25 07:49:52

问题


I am creating an EXP multiplier and I do not know how to separate multipliers.

My Aim: My aim is to make it so that the multiplier from 'checkbox5.checked = true' will not multiply by the rest of checkboxes but just add its product. If 'checkbox1.checked = true' it will multiply the EXP, which is the input amount by 2. So if checkbox4 is checked, it will multiply the EXP by 1.5 again. So 2x1.5 = 3

However for checkbox5, which multiplier is x1.1, I do not want it to be multiplying the rest of the exp, which means 2x1.5x1.1 = 3.3 but rather adding it in separately, but still displaying the answer in one result which i mean is 2x1.5 + 1.1 = 4.1.

So it means if the input is '2' and checkbox 1,4 and 5 is checked then the answer will be 8.2 not 6.6.

But i do not know how to that, please help!

Here is my code:

Dim exp2 As Double
Dim exptotal As Double
Dim exp As Double
If IsNumeric(TextBox9.Text) Then
    exp = CDbl(TextBox9.Text)
    exp2 = CDbl(TextBox9.Text)
Else
    MsgBox("Please input a number.")
End If
If CheckBox1.Checked = True Then
    exp = exp * 2
End If
If CheckBox2.Checked = True Then
    exp = exp * 1.5
End If
If CheckBox3.Checked = True Then
    exp = exp * 1.3
End If
If CheckBox4.Checked = True Then
    exp = exp * 1.5
End If
If CheckBox5.Checked = True Then
    exp2 = exp + (exp2 * 1.1)
End If

exptotal = exp + exp2

If exp <> 0 Then
    Label37.Text = totalexp
End If

Please help!!

来源:https://stackoverflow.com/questions/30726319/vb-net-how-to-add-different-multipliers-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!