Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Object reference not set to an instance of an object.+ Sourabh

Object reference not set to an instance of an object.+ Sourabh

Scheduled Pinned Locked Moved Visual Basic
database
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dot Net Jantu
    wrote on last edited by
    #1

    Hi, Kindly see the codes below: On the next button I call ShowReconcileStatement. In ShowReconcileStatement I call GetGridTotal. When I call the GetGridTotal, Before it enters the procedure, I get an exception as : Object reference not set to an instance of an object. The code where the exception occurs I have underlined. Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click Try tcBankReco.SelectedIndex = 1 ShowReconcileStatement() Catch ex As Exception End Try End Sub Private Sub ShowReconcileStatement() Try Dim i As Integer Dim bnkDep As Double = 0 Dim bnkWith As Double = 0 bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index) bnkDep = GetGridTotal(dgtmp, dgtmp.Cols(DEPOSITS).Index) Catch ex As Exception End Try End Sub Private Function GetGridTotal(ByVal dg As C1.Win.C1FlexGrid.C1FlexGrid, ByVal col As Int16) As Double Try With dg Dim rg As CellRange = .GetCellRange(1, col, dg.Rows.Count - 1, col) Dim agg As String = .Aggregate(AggregateEnum.Sum, rg) Return CDbl(agg) End With Catch ex As Exception Return 0 ShowMessage(ex.Message, 30) Finally End Try End Function Please suggest..

    Thanks and Regards,

    M D 2 Replies Last reply
    0
    • D Dot Net Jantu

      Hi, Kindly see the codes below: On the next button I call ShowReconcileStatement. In ShowReconcileStatement I call GetGridTotal. When I call the GetGridTotal, Before it enters the procedure, I get an exception as : Object reference not set to an instance of an object. The code where the exception occurs I have underlined. Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click Try tcBankReco.SelectedIndex = 1 ShowReconcileStatement() Catch ex As Exception End Try End Sub Private Sub ShowReconcileStatement() Try Dim i As Integer Dim bnkDep As Double = 0 Dim bnkWith As Double = 0 bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index) bnkDep = GetGridTotal(dgtmp, dgtmp.Cols(DEPOSITS).Index) Catch ex As Exception End Try End Sub Private Function GetGridTotal(ByVal dg As C1.Win.C1FlexGrid.C1FlexGrid, ByVal col As Int16) As Double Try With dg Dim rg As CellRange = .GetCellRange(1, col, dg.Rows.Count - 1, col) Dim agg As String = .Aggregate(AggregateEnum.Sum, rg) Return CDbl(agg) End With Catch ex As Exception Return 0 ShowMessage(ex.Message, 30) Finally End Try End Function Please suggest..

      Thanks and Regards,

      M Offline
      M Offline
      Mustafa Ismail Mustafa
      wrote on last edited by
      #2

      Your dgtmp FlexGrid is not instantiated.

      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook "There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib "Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"

      1 Reply Last reply
      0
      • D Dot Net Jantu

        Hi, Kindly see the codes below: On the next button I call ShowReconcileStatement. In ShowReconcileStatement I call GetGridTotal. When I call the GetGridTotal, Before it enters the procedure, I get an exception as : Object reference not set to an instance of an object. The code where the exception occurs I have underlined. Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click Try tcBankReco.SelectedIndex = 1 ShowReconcileStatement() Catch ex As Exception End Try End Sub Private Sub ShowReconcileStatement() Try Dim i As Integer Dim bnkDep As Double = 0 Dim bnkWith As Double = 0 bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index) bnkDep = GetGridTotal(dgtmp, dgtmp.Cols(DEPOSITS).Index) Catch ex As Exception End Try End Sub Private Function GetGridTotal(ByVal dg As C1.Win.C1FlexGrid.C1FlexGrid, ByVal col As Int16) As Double Try With dg Dim rg As CellRange = .GetCellRange(1, col, dg.Rows.Count - 1, col) Dim agg As String = .Aggregate(AggregateEnum.Sum, rg) Return CDbl(agg) End With Catch ex As Exception Return 0 ShowMessage(ex.Message, 30) Finally End Try End Function Please suggest..

        Thanks and Regards,

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Dot Net Jantu wrote:

        bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index)

        Your code is assuming that dgtmp.Cols(WITHDRAWLS) is returning an object. If it doesn't return an object, meaning that it returns Nothing, calling the Index property on it will throw this exception.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups