vb.net - Why am I getting a NullReferenceExeption with listbox.SelectedIndex -


i run little piece of code kind of activity log window.

sub writetolog(i string)     try         'outfile.write(datetime.now.tostring("mm/dd/yyyy - h:mm:ss:fffffff") & "--->" & & vbcrlf)         console.writeline(datetime.now.tostring("hh:mm:ss:ff") & " - " & i)         if string.isnullorwhitespace(i) = false loglb.items.add(datetime.now.tostring("[" & "mm/dd/yy - hh:mm:ss:ff") & "] -- " & i) 'else msgbox(i & " nothing!")         if loglb.items.count >= 100 loglb.items.removeat(0)         if loglb.items.count > 0 loglb.selectedindex = loglb.items.count - 1     catch ex exception         console.write(ex)     end try end sub 

so works of time, reason @ seemingly random times null exception , points end of line @

loglb.items.count - 1 

i don't know why. ideas?


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -