tags:

views:

54

answers:

1

Hi, i have an VB.NET application with few functions i need to debug (like ie. Assert in C#). Is it possible and how i do that ?

    Public Shared Function createNumberArrayList(ByVal startValue As Integer, _
                                             ByVal endValue As Integer, _
                                             Optional ByVal isBackwards As Boolean = False) As ArrayList
    Dim nArrayList As New ArrayList()
    If Not isBackwards Then
        For index As Integer = startValue To endValue
            nArrayList.Add(index)
        Next
    Else
        For index As Integer = endValue To startValue
            nArrayList.Add(index)
        Next
    End If
    Return nArrayList
End Function

Basically what i need is to enter few values and see if the function works and returns proper ArrayList.

Thanks

+1  A: 

Assert is not specific to C#, it's a framework method, so it can be used in any .NET language. You can do something like this:

Diagnostics.Debug.Assert(nArrayList.Count > 0)

Edit:

I'm not sure whether Debug.Assert works in ASP.NET applications or not, I found contradictory info on the web about this... If it doesn't work, check out this CodeProject article.

Meta-Knight
How do i check this ? I mean how do i make VS to execute Debug.Assert ? Sorry for noobness
eugeneK
Just add asserts in your code, then run your website in debug, and it will show a popup if an Assert fails. If it doesn't... check my edit.
Meta-Knight
i did Debug.Write() and did nothing...
eugeneK
It will write a message in the Output window by default.
Meta-Knight