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
D

Dave 10169531

@Dave 10169531
About
Posts
4
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Object reference not set to an instance of an object.
    D Dave 10169531

    I am getting the message "Object reference not set to an instance of an object." I know I am not initializing the variable correctly but I cannot find an example that can show me how. I am using the class ChargeBatch with ChargeItem to build data to be passed via a JSON string. I can deserialize in the class fine but when I try to populate the class ChargeItem to serialize it into a JSON string, I get the above error. Thank you in advance for any and all help. Below is my code.

    Public Class ChargeBatch
        Public Property ChargeItems As List(Of ChargeItem)
        Public Property CommunityKey As Long
        Public Property EffectiveDate As String
    End Class
    'Charge Items
    Public Class ChargeItem
        Public Property OwnerKey() As Long
        Public Property ChargeCodeKey() As Long
        Public Property Amount() As Double
    End Class
    

    Module APIARcharge

    Sub Main(ByVal ParamArray args() As String)
    
            Dim iMyChrgItem As Integer = 0
    
            Dim CommID As String = Nothing
            Dim ARFile As String = Nothing
    
            If args.Length < 2 Then
                Throw New ApplicationException("Invalid or no parameters passed to this module.")
                End
            Else
                CommID = args(0)
                ARFile = args(1)
            End If
    
            If Not File.Exists(ARFile) Then
                Throw New ApplicationException(String.Format("File \[{0}\] does not exist.", ARFile))
                End
            End If
    
            ' Open input file and post
            Dim chgbtch As New ChargeBatch
            Using mystream As StreamReader = New StreamReader(ARFile)
                Dim recs As String
                While Not mystream.EndOfStream
                    recs = mystream.ReadLine().TrimEnd
                    chgbtch.ChargeItems(iMyChrgItem).OwnerKey = (CInt(Mid(recs, 11, 10)))
                    chgbtch.ChargeItems(iMyChrgItem).ChargeCodeKey = CInt(Mid(recs, 21, 10))
                    chgbtch.ChargeItems(iMyChrgItem).Amount = CDbl(Mid(recs, 47, 9))                    chgbtch.CommunityKey = CInt(Mid(recs, 1, 10))
                    chgbtch.EffectiveDate = Format(Mid(recs, 41, 6), "mm/dd/YYYYT00:00:00")
                    iMyChrgItem = iMyChrgItem + 1
                End While
            End Using
    
            Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(chgbtch)
    

    End Sub

    Visual Basic help json tutorial

  • Home Office // Working From Home
    D Dave 10169531

    I agree I have been working out of my home office since 2001. I have a set start time and breaks. You have to be dedicated to do this and not let the outside distractions upset your routine of work. Not only do you save time in commuting but you are saving money in gas and where a tear on your vehicle. Good luck.

    The Lounge

  • listview won't display data populated in vb6
    D Dave 10169531

    Thanks I am sorry i thought i deleted this thread. I did resolve the problem. And yes I am migrating the complete application to newer code base using VS2013. Thanks again

    Visual Basic question

  • listview won't display data populated in vb6
    D Dave 10169531

    This is now solved. I can walk the code through and watch the data populate but nothing other than the headings are displayed. I am not sure what is different with this compared to others that have been done and i have even compared code and they all work the same so there must be something i am over looking.

    Dim nUserID As Long
    Dim sToday As String
    Dim sUser As String
    Dim sSQL As String

    Dim li      As ListItem
    
    Me.lvMain.ListItems.Clear
    
    'rsUser.MoveFirst
    
    Set dbGlob = OpenDatabase(GenPath & "WORORDGB.MDB")
    'Set rsCal = Nothing
    sToday = sDate
    Select Case UCase(sType)
    
        Case "ALL"            'All
            
            sSQL = "SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] <> 0 ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]"
            Set rsCal = dbGlob.OpenRecordset(sSQL)
            rsCal.MoveLast
            rsCal.MoveFirst
            
        Case "WO"      'WO
        
            Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] = " & CInt(Trim(Me.cmbWOID.Text)) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]")
            rsCal.MoveLast
            rsCal.MoveFirst
        
        Case "WR"          'WORKER
        
            Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] <> 0 AND \[UserID\]=" & CLng(Me.cmbuserID.Text) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]")
            rsCal.MoveLast
            rsCal.MoveFirst
        
        Case "WRWO"         'Worker - WO
        
            Set rsCal = dbGlob.OpenRecordset("SELECT \* FROM \[Accum\] WHERE \[Type\] = 'LABOR' AND \[Closed\]= 0 AND \[WOCounter\] = " & CInt(Trim(Me.cmbWOID.Text)) & " AND \[UserID\]=" & CLng(Me.cmbuserID.Text) & " ORDER BY \[Date\],\[UserID\],\[Start\],\[WOCounter\]")
            rsCal.MoveLast
            rsCal.MoveFirst
    
    End Select
    
    With Me.lvMain
        '.ListItems.Clear
        If rsCal.RecordCount = 0 Then
            Set li = .ListItems.Add(1, "ID" & rsUser.Fields("ID").Value, "Empty", , 4)
            Exit Sub
        End If
        
        For X = 1 To rsCal.RecordCount
                
            If IsNull(rsCal.Fields("UserID").Value) Then
                sUser = rsCal.Fields("Desc").Value
            Else
                For Y = 0 To cmbUser.ListCount - 1
                    If CLng(rsCal.Fields("UserID").Val
    
    Visual Basic question
  • Login

  • Don't have an account? Register

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