I just started creating a project in Visual Studio. I am completely new to this. I have already made a form, where I read data via modbus. That all works perfectly.
But sometimes I need to be able to change the settings in the form to communicate with modbus. If the settings are numbers, there is no problem. But if it is a word, then i get a error.
This is my code:
Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
ModbusRTUCom1.Parity = ComboBox3.SelectedItem
End Sub
The error message is:
--> System.InvalidCastException: 'The conversion from string None to type Integer is invalid.'
I have a combobox with 3 items; None, Odd and Even. I already tried a lot of things i found on Google, but it does not work :'(.
The Error:
This is the project:
This is the itemlist for the combo:
EDIT: Nothing worked for me. Then i suddenly did something simple!
Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
ModbusRTUCom1.Parity = ComboBox3.SelectedIndex
End Sub