Window form Application

Am building windows form application using VS2010.
I created a class that generate patientNo.
Now am testing to see if the class is functioning as expected , using message box to dispaly
patientNo.
when i run the application and set Gender from a combobox and click on the generate
Button, i got an error: null reference exception point to the variable reading selectedvalue from the combobox. pls help
here is the code:
Question.txt
AtourayAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You could check for null like this:

    if (comboBox2.SelectedValue != null)
    {
        // ... rest of your code ...
    }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.