0
我有一個計算,其中我將面板數乘以瓦特數,並將輸出轉換爲KW。這是我的VB代碼。計算結果,如果組合框的值已更改
Total_watt = (Watt_In * Npanel)/1000.0
如果我更改DomainUpDown,將會生成結果。如果我選擇一個ComboBox項目,值不會改變。我已經添加了幾行來處理組合框,但我正在逐漸
「」類型的異常出現在Microsoft.VisualBasic.dll中,但在用戶代碼中 其他信息沒有處理錯誤:轉換從字符串「」到類型「整數」無效。
沒有ComboBox代碼,它工作正常,但無法從ComboBox中獲取數據。
Public Class Solar_Panel
Dim Total_watt As Double
Dim Npanel As Integer
Dim Watt_In As Integer
Private Sub Solar_Panel_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RadioButton_Direct_Data_In.Select()
Watt_In = CInt(ComboBox_PanelWatt.SelectedItem)
Npanel = CInt(DomainUpDown_NModule.Text)
Total_watt = (Watt_In * Npanel)/1000.0
Label_Tout.Text = CStr(Total_watt)
End Sub
Private Sub DomainUpDown_NModule_SelectedItemChanged(sender As Object, e As EventArgs) Handles DomainUpDown_NModule.SelectedItemChanged
Watt_In = CInt(ComboBox_PanelWatt.SelectedItem)
Npanel = CInt(DomainUpDown_NModule.Text)
Total_watt = (Watt_In * Npanel)/1000.0
Label_Tout.Text = CStr(Total_watt)
End Sub
Private Sub ComboBox_PanelWatt_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox_PanelWatt.SelectedIndexChanged
If ComboBox_PanelWatt.Text = True Then
Watt_In = CInt(ComboBox_PanelWatt.SelectedItem)
Npanel = CInt(DomainUpDown_NModule.Text)
Total_watt = (Watt_In * Npanel)/1000.0
Label_Tout.Text = CStr(Total_watt)
End If
End Sub
End Class