dimanche 16 mai 2021

how to optimize an if condition for multiple values of same variable in vb

How to write an If Condition having a single variable but multiple values.

Ex : 'Consider I have employee details filled in a data table

If (dt.Rows(0).Items("Id").ToString() = "548" Or dt.Rows(0).Items("Id").ToString() = "78787" Or dt.Rows(0).Items("Id").ToString() = "787" Or dt.Rows(0).Items("Id").ToString() = "11" Or dt.Rows(0).Items("Id").ToString() = "025" Or dt.Rows(0).Items("Id").ToString() = "568") Then
MessageBox.Show("INSIDE")
End if

How can I optimize this If condition?

Aucun commentaire:

Enregistrer un commentaire