SIMIN Posted January 8, 2009 Posted January 8, 2009 Private ReportLog As StringBuilder Private Sub DoThat() 'We didn't assign any value to the ReportLog so here we want to check if it's empty or not? If ReportLog IsNot Nothing And ReportLog.Length > 0 Then ' End IF End Sub The problem is that "If ReportLog IsNot Nothing And ReportLog.Length > 0 Then" itself throws an exception! A first chance exception of type 'System.NullReferenceException' occurred in MyApp.exe A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll How should I check that variable? Thank you :) Quote
Administrators PlausiblyDamp Posted January 8, 2009 Administrators Posted January 8, 2009 For .Net 2 and higher If ReportLog IsNot Nothing AndAlso ReportLog.Length > 0 Then otherwise you would need to use a couple of If statements nested If ReportLog IsNot Nothing Then If ReportLog.Length > 0 Then 'do stuff here Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.