Results 1 to 7 of 7

Thread: [2005] Try/Catch Code correctness, advice(seeking).

Threaded View

  1. #1

    Thread Starter
    Lively Member smilbuta's Avatar
    Join Date
    Apr 2005
    Location
    Orlando
    Posts
    104

    [2005] Try/Catch Code correctness, advice(seeking).

    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.


    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
    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!!!
    Last edited by smilbuta; Apr 18th, 2007 at 10:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width