Yes, as Hugo said ... it's not really saying don't initially set an object to Nothing, it's saying that in order to use the With, you need to be sure your object is instantiated first ... which makes sense! There's absolutely nothing wrong with initially setting an object to Nothing. I do it frequently when I have situations where I want to determine whether an object needs to be instantiated or not by first checking If MyObject = Nothing.
~~Bonnie
>This page details some possibiltiies of obtaining the famous "Object variable or With block variable not set " error:
>
>
http://msdn.microsoft.com/en-us/library/5szkzs17(v=vs.80).aspx>
>In my code, one of the standard is to always initialize everything to a default value. So, here is an example:
>
>
> Dim lcHtml As String = ""
> Dim ldAddDate As Date = Nothing
> Dim llBlankDate As Boolean = False
> Dim llForceGive As Boolean = False
> Dim llHelpGive As Boolean = False
> Dim llHelpRemove As Boolean = False
> Dim llIn As Boolean = False
> Dim llPrevious As Boolean = False
> Dim llReply As Boolean = False
> Dim llSolution As Boolean = False
> Dim llSolutionGive As Boolean = False
> Dim llSolutionRemove As Boolean = False
> Dim llSolutionSysop As Boolean = False
> Dim llUnmarkSysop As Boolean = False
> Dim lnCounter As Integer = 0
> Dim lnLocation As Integer = 0
> Dim lnNoReply As Integer = 0
> Dim lnOriginalMember As Integer = 0
> Dim lnPoint As Integer = 0
> Dim lnUnmarkSysop As Integer = 0
> Dim lnUserHeadNoReply As Integer = 0
> Dim loControlLabel As System.Web.UI.WebControls.Label = New System.Web.UI.WebControls.Label
> Dim loControlLiteral As System.Web.UI.WebControls.Literal = New System.Web.UI.WebControls.Literal
> Dim loControlTable As System.Web.UI.WebControls.Table = New System.Web.UI.WebControls.Table
> Dim loDataProvider As Framework.Framework.Data = New Framework.Framework.Data(oProcess)
> Dim loRow As DataRow = Nothing
> Dim loUpdate As Framework.Framework.Update = New Framework.Framework.Update(oProcess)
>
>
>But, referring to that page, point #2 says to make sure to not use an object variable set to Nothing.
>
>I have a situation that happens once every one hundred thousand this approximately. So, it is very difficult to simulate. So, I cannot locate exactly where it happens. But, this error reported is within the biggest transaction being executed on this site. Basically, it is being done between 5000 to 10000 times a day. So, in regards to Nothing, could it be that the following line could cause this from time to time:
>
>
> Dim loRow As DataRow = Nothing
>
>
>As I said, this hit works ok but once every hundred thousand hits approximately, it will generate an error. But, executing the page as is, will work at 99.99% of the time.
>
>If this could be related to this line, then it is a bad bug, already reported by Microsoft, which should be fixed soon. Because, when not doing so, assuming just like this:
>
>
> Dim loRow As DataRow
>
>
>This creates some green warning which is irritating me if I have defined a variable which is not being used.