計算機的輸入數字欄就是最少要10 最高是32767
這樣才能跟基本數值參考(預設對應資料),計算出來的結果一樣
當數字欄輸入10 數值欄選擇力量 則按下計算按鈕後會顯示 12物攻
例如: 10力量 = 12物攻 那100力量就是120物攻
在程式碼上預設每一種最少輸入值是10,若低於10的話會跳出小方塊提醒。
不知道這樣做出來會不會很複雜..!
以下是我臨時製作的優惠計算機,只是不曉得該怎麼改成數值計算機!?
語法:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim buy As Integer, pay As Integer
Dim msg As String
buy = Val(TextBox1.Text)
If buy > 1000 Then
pay = buy * 0.8
If buy > 2000 Then
pay = pay - 100
Else
pay = pay - 50
End If
Else
If buy > 500 Then
pay = buy * 0.95
End If
End If
TextBox2.Text = pay
buy = Val(TextBox1.Text)
If buy > 1000 Then
pay = pay * 0.8
If buy > 2000 Then
msg = "超過 2000 元, 先打 8 折再減 100 元。"
pay = pay - 100
Else
msg = "超過 1000 元, 先打 8 折再減 50 元。"
pay = pay - 50
End If
Else
If buy > 500 Then
msg = "金額未超過 500 元打 95 折。"
pay = pay * 0.95
End If
End If
TextBox2.Text = pay
Label3.Text = msg
TextBox1.Focus()
TextBox1.SelectAll()
End Sub
End Class