Horrible Code Example

27. January 2009 21:57

This is by far the worse code I have ever come across in .NET.  For those of you that understand it you'll laugh, for those of you that don't, just don't ever do something like this.

This is supposed to be code to pull the value(s) selected out of a listBox control with an ID of "selstatus"......enjoy :)

 If Request("ctl00$PageBody$selstatus") <> "" Then
            stat = Request("ctl00$PageBody$selstatus").Split(",".ToCharArray)
            For Each st In stat
                If st.Equals("5") Then
                    For Each st1 In stat
                        If st1.Equals("2") And st1.Equals("3") Then
                        ElseIf st1.Equals("2") And st1 <> "3" Then
                            qur.Append("3,")
                        ElseIf st1 <> "2" And st1.Equals("3") Then
                            qur.Append("2,")
                        ElseIf st1 <> "2" And st1 <> "3" Then
                            qur.Append("2,3,")

                        End If
                    Next

                Else
                    qur.Append(st + ",")
                End If
                stID = stID & "$" & st
            Next
End If

Tags:

ASP.NET

blog comments powered by Disqus



My Random Thought

I think the OCW is a great thing to have available to those who are in school, just finished school or just want to educate themself

http://ocwconsortium.org/

John On Twitter

Discounts