Hello community.
I am handling a nothing value for a set of variables and i want to know what is the best way to do this code wise. This is not an error question but more of how i can improve consiceness of the code.
App info: the combo boxes (usename and status) are databound to tables in sql database. Im dealing with an error if a user trys to type in the feild and submit. since the user enterd data has a selected value of Nothing according to VS , i can throw an error informing the user of his stup.. AHEM!.. issue.
Currently my code looks like the following.
The core of my question deals with my IF statments and is ther a more efficient way to make that code more consice. In the actual app i have 7 combo boxes and the over all code would be slightly long and seemingly bloated... any advice welcome.. Thanx!!!Code:Try If cboUserName.SelectedValue Is Nothing Then MessageBox.Show("woops, invalid name") Else userIdValG = CStr(cboUserName.SelectedValue) End If If cboStatus.SelectedValue Is Nothing Then MessageBox.Show("woops, invalid status.") Else statusIdValG = CStr(cboStatus.SelectedValue) End If Catch ex As Exception MessageBox.Show(ex.Message) End Try




Reply With Quote