看板 Visual_Basic 關於我們 聯絡資訊
Dim rate As Single = 0.05 Dim amout As Integer Dim total As Single = 0 Sub show() If CheckBox1.Checked Then total += 5500 * TextBox1.Text End If If CheckBox2.Checked Then total += 3500 * TextBox2.Text End If total += total * rate TextBox3.Text = total Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, RadioButton2.CheckedChanged If RadioButton1.Checked Then rate = 0.05 Else rate = 0.1 End If show() End Sub我想問大大們 Dim total As Single = 0 如果宣告在sub show()這格副程式裡面...跟宣告在全域變數有什麼差?? 執行局果不ㄧ樣 那如果是rate呢 如果宣告在副程式裡會有什麼差嗎 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.166.73.185
MOONRAKER:那樣Total將沒有累加效果 01/08 15:10
YiJyun:rate宣告在副程式裡,RadioButton1_CheckedChanged這裡會 01/08 21:31
YiJyun:rate這個變數宣告 01/08 21:32
YiJyun:會找不到 01/08 21:32