如何擺脫組合框中的值以適應examgrade
中的公式?無效的演員表達?
我試圖通過在MSDN上查找來解決它,但無法弄清楚。 我試過使用Examgrade =().ToString
但沒有奏效。
希望你們能指點我正確的方向。僅供參考這是我的第一個真正的程序,我成功地在C#中做了一次,但刪除了源文件,所以這是Visual Basic,並且更容易實現這一目標。
星號標記的問題行
Public Class Calculator
Dim quarter3 As Integer
Dim quarter4 As Integer
Dim desiredgrade As String
Dim examgrade As String
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
quarter3 = TextBox1.Text
quarter4 = TextBox2.Text
desiredgrade = ComboBox1.Text
****examgrade = ((desiredgrade - (quarter3 * 0.4) - _
(quarter4 * 0.4))/0.2)****
If examgrade > 100 Then
Label5.Text = examgrade + " YOLO"
ElseIf examgrade < 0 Then
Label5.Text = "Impossible"
Else
Label5.Text = examgrade
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles _
ComboBox1.SelectedIndexChanged
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
A = 90
B = 80
C = 70
D = 60
ComboBox1.EndUpdate()
End Sub
End Class
如果您將** Option Strict On **作爲該文件的第一行,它將向您顯示變量類型與您分配給它們的內容不匹配的位置。另外,爲什麼ComboBox1.EndUpdate()沒有相應的ComboBox1.BeginUpdate(),特別是因爲你沒有改變ComboBox1? –