thebatfink
Well-known member
- Joined
- Mar 29, 2012
- Messages
- 47
- Programming Experience
- Beginner
Hi, I have run across a problem and I am struggling to understand how to fix it (the IDE doesn't seem able to auto correct the problem).
I have a little bit of code that uses the Microsoft.Office.Interop, however I suspect this is irrelevant to the problem and it is a general coding issue, so hopefully I have hit the correct sub forum
So.. as the title explains, I have hit this error. I had a working program, no problems. However today I decided to enable Option Strict and Option Explicit and set about making all the nessicary changes to my now apparent badly written code!
So the IDE now complains that Option Strict disallows operands of type Object for operator '=' and now requires the use of the 'Is' operator. This has been fine until I now hit this statement trying to test for False, if I change to 'Is False', this then throws the errors as per the title.
So my question is, when something is Returning True or False as in the case of .HasFormula (MSDN Link), how do I test in my If blocks with Option Strict On?!
Any help would be much appreciated! Thanks!
EDIT: The only thing I can think of is to try and convert the .HasFormula to an Integer and then test if its 0?
but is this correct? Am I totally missing something?
I have a little bit of code that uses the Microsoft.Office.Interop, however I suspect this is irrelevant to the problem and it is a general coding issue, so hopefully I have hit the correct sub forum
So.. as the title explains, I have hit this error. I had a working program, no problems. However today I decided to enable Option Strict and Option Explicit and set about making all the nessicary changes to my now apparent badly written code!
VB.NET:
If PlanWorkSheet.Range("A1").HasFormula = False Then
So the IDE now complains that Option Strict disallows operands of type Object for operator '=' and now requires the use of the 'Is' operator. This has been fine until I now hit this statement trying to test for False, if I change to 'Is False', this then throws the errors as per the title.
So my question is, when something is Returning True or False as in the case of .HasFormula (MSDN Link), how do I test in my If blocks with Option Strict On?!
Any help would be much appreciated! Thanks!
EDIT: The only thing I can think of is to try and convert the .HasFormula to an Integer and then test if its 0?
VB.NET:
If CInt(PlanWorkSheet.Range("A1").HasFormula) = 0 Then
but is this correct? Am I totally missing something?
Last edited: