Results 1 to 6 of 6

Thread: What is wrong with this code

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    6

    What is wrong with this code

    Hello,

    For last few days I'm trying everything to solve problem with this code but I still can't find any solution. Please, if you know what could it be, help.

    There is code:

    Code:
    Dim ArtikalId, StopaId As Integer
    Dim DefCijena, DefStopa As Double
    If Me.NarudzbeKupacaStavkeDgr.Columns(e.ColumnIndex).Name = "Artikal" Then
    
                ArtikalId = Me.NarudzbeKupacaStavkeDgr.Rows(e.RowIndex).Cells("Artikal").Value
                Dim ArtikliRedak As DataRow = Me.NarudzbeKupacaDataSet.Tables("ListaArtikli").Rows.Find(ArtikalId)
                If ArtikliRedak IsNot Nothing Then
                    DefCijena = ArtikliRedak("ArtikalCijena")
                    NarudzbeKupacaStavkeDgr.Rows(e.RowIndex).Cells("Cijena").Value = DefCijena
                    StopaId = ArtikliRedak("ArtikalStopa")                
                End If
    
                Dim StopeRedak As DataRow = Me.NarudzbeKupacaDataSet.Tables("SifarnikArtikli_StopePoreza").Rows.Find(StopaId)
                If StopeRedak IsNot Nothing Then
                    DefStopa = StopeRedak("StopaStopa") 
                    NarudzbeKupacaStavkeDgr.Rows(e.RowIndex).Cells("PdvStopa").Value = DefCijena
                End If
    
            End If
    I got value of ArtikalId as well as DefCijena and StopaId but I don't get value of DefStopa. I checked names and values, there should be value of DefStopa.

    When I put second part of this code, which should provide me value of DefStopa in try..catch like this:

    Code:
    Try
                    Dim StopeRedak As DataRow = Me.NarudzbeKupacaDataSet.Tables("SifarnikArtikli_StopePoreza").Rows.Find(StopaId)
                    DefStopa = StopeRedak("StopaStopa")
                    NarudzbeKupacaStavkeDgr.Rows(e.RowIndex).Cells("PdvStopa").Value = DefStopa 
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
    I got message: "Object reference not set to an instance of an object".

    Thanks in advance.
    Last edited by Mirnes; Jan 3rd, 2009 at 10:04 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width