none
VS 2013 vb.net warning Variable '' is used before it has been assigned a value. A null reference exception could result at runtime_ RRS feed

  • Question

  • VS 2013 vb.net warning Variable '' is used before it has been assigned a value. A null reference exception could result at runtime.        

    On the following variable names:

    ndAuthorFullname

    ndMatterName

    ndClientName

    I thought my declarations were correct.

    Heres my code.  Can someone pls let me know whats going on

    TIA

    Public Function GetDMRef(ByVal worddoc As WordDocument, ByVal type As Integer) As String
    
                Dim nddocid As String
                Dim ndVersion As String
                Dim ndFileName As String
                Dim ndAuthor As String
                Dim ndClient As String
                Dim ndMatterID As String
                Dim ndDescription As String
                Dim ndCabinet As String
    
                Dim ndAuthorFullname As String
                Dim ndClientName As String
                Dim ndMatterName As String
    
                Dim ndDateCreated As String
                Dim eDocsNo As String
                Dim eDocsParentFolder As String
                Dim Classification As String
                Dim SubClassification As String
                Dim blnPhysicalExists As String
                Dim blnQACompleted As String
                Dim TeamOrProject As String
                Dim TopCategory As String
                Dim Activity As String
    
                Dim ndArrayPack As String
                Dim ndArray() As String
    
                If worddoc.Document.Application.Visible = False Then Return Nothing
    
                Try
    
                    ndArrayPack = worddoc.Document.Application.Run("GetNetDocsDocInfo").ToString
                    ndArray = ndArrayPack.Split("|")
    
                    If Not String.IsNullOrEmpty(ndArrayPack) Then
                        nddocid = ndArray(0)
                        ndVersion = ndArray(1)
                        ndFileName = ndArray(2)
                        ndAuthor = ndArray(3)
                        ndAuthorFullname = ndArray(4)
                        ndClient = ndArray(5)
                        ndClientName = ndArray(6)
                        ndMatterID = ndArray(7)
                        ndMatterName = ndArray(8)
                        ndDescription = ndArray(9)
                        ndCabinet = ndArray(10)
    
                        ndDateCreated = ndArray(11)
                        eDocsNo = ndArray(12)
                        eDocsParentFolder = ndArray(13)
                        Classification = ndArray(14)
                        SubClassification = ndArray(15)
                        blnPhysicalExists = ndArray(16)
                        blnQACompleted = ndArray(17)
                        TeamOrProject = ndArray(18)
                        TopCategory = ndArray(19)
                        Activity = ndArray(20)
    
                    Else
                        ndAuthor = ""
                        ndClient = ""
                        ndMatterID = ""
                        ndDescription = ""
                    End If
    
    
                    Dim omyob As New DMS.DM5Library(worddoc)
                    Dim ndo As Object
                    ndo = CreateObject("ndOffice.EchoingDataService")
                    Dim docInfo As Object
                    docInfo = ndo.getDocumentInfo(worddoc.Document.Application.ActiveDocument.FullName)
    
    
                   If Not omyob Is Nothing Then
    
                        If type = 1 Then Return ndClient & "-" & ndMatterID
                        If type = 2 Then Return ndDescription
    
                        If type = 3 Then Return ndAuthorFullname
                        If type = 4 Then Return ndClient
                        If type = 5 Then Return CStr(ndMatterID)
    
                        If type = 7 Then Return ndMatterName
                        If type = 8 Then Return ndClientName
    
                    Else
    
                        Return String.Empty
                    End If
    
    
                Catch argEx As ArgumentException
                    Logger.Message(argEx)
                    Return String.Empty
                Catch ex As Exception
                    Corrs.Common.Logger.Log(Me.GetType(), ex)
                    Return String.Empty
                End Try
                Return String.Empty
            End Function
    

    The warnings appear in the following block of code

    Thursday, January 21, 2016 6:11 AM

Answers

All replies