If you are going use If statements to compare a variable/control value against multiple values, it is simpler to use a Select Case. One way would be like this:
However, as it is this wont save much typing... thankfully you can use more than one value per case (simply separate them using commas), so you can do this:Code:Select Case MaskedTextBox1.Text Case "H" MsgBox "MaskedTextBox1.Text equals 'H'" Case "Li" MsgBox "MaskedTextBox1.Text equals 'Li'" ... End Select
It would also be possible to loop the elements arrays, but as your data doesn't contain the letters on their own it would be fairly "messy" code, and so it may be better to avoid that.Code:Select Case MaskedTextBox1.Text Case "H", "Li", "Na", "K", "Rb", "Cs", ... TextBox1.Text = print(0) End Select




Reply With Quote
