0
votes

The framework has recently been updated on my computer and I've updated from Visual Studio 2008 to 2010, now there is a part of my code that won't work.

Public Property ItemCount() As Integer
        Get
            Dim val As Object = ViewState("ItemCount")
            Return If(val IsNot Nothing, CInt(val), 0)
        End Get
        Set(ByVal value As Integer)
            ViewState("ItemCount") = value
        End Set
    End Property

The "Return If(val IsNot Nothing, CInt(val), 0)" part of the code does not work ERROR: Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30201: Expression expected.

Source Error:

Line 21: Get
Line 22: Dim val As Object = ViewState("ItemCount")
Line 23: Return If(val IsNot Nothing, CInt(val), 0)
Line 24: End Get
Line 25: Set(ByVal value As Integer

Is there a converter that I can use to bring this part of the code upto date, I'm assuming is the code that's now been outdated. Thanks.

1

1 Answers

1
votes
Get
        Dim val As Object = ViewState("ItemCount")
        ' Return If(val IsNot Nothing, CInt(val), 0)
        If val Is Nothing Then
            Return 0
        Else
            Return (CInt(val))
        End If

    End Get

Try This, it should work.