Sub Decode()
Dim OpenXmlDialog As New OpenDialog
OpenXmlDialog.Title = "Select A Riivolution XML File"
OpenXmlDialog.Filter = RiivolutionFileType.RiivolutionXMLFile
OpenXmlDialog.InitialDirectory = SpecialFolder.Documents
TheFile = OpenXmlDialog.ShowModal
If TheFile <> Nil Then
Try
TheRiivolutionXmlDocument.LoadXml(TheFile) // <-- This is the NilObjectException.
Catch error As XmlException
MsgBox "XML Error: " + error.Message
End Try
If TheRiivolutionXmlDocument.DocumentElement.Name = "wiidisc" = False Then // <-- Can I do this? (if text = value = true)
MsgBox "Please supply a XML file that was created for Riivolution!"
Else
End If
End If
End Sub
tl;dr:
I get a NilObjectException at TheRiivolutionXmlDocument.LoadXml(TheFile). I tried putting a path variable like “NativePath” and no go.
Can I use the If statement like this: “If Thing.Text = “Hello” = False Then … End If” If not, then how can I use “If Not” or something similar?
Well, I thought you were confused as to where the NilObjectException was coming from, thinking it was generated by TheFile. It also didn’t occur to me that that you didn’t know that you had to use “new” to create instances of objects, so that’s my bad.
On the other hand, I was trying to help and just got insulted for my trouble, so you won’t have to worry about any of my “unhelpful” answers in the future.
“= false” does work. The first comparison yields a boolean, which is then compared to false–a comparison which always yields the same result as the Not operator. (That said, using <> is probably better than either, as it simply makes one comparison instead of two comparisons or a comparison and a reversal.)
You’re right, of course, but there are times when you might need to write it that way, perhaps for clarity. In those cases, use parens to make it clear:
if ( this = that ) = false then // I'd never do this myself, but...
Or, more likely:
dim status as boolean = ( this = that )
I should stress that the parens are not required there, just, IMO, easier to read.