![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
more beginner questions Is option strict recommended practice in general with vbnet? if i turn it on i get hundreds of errors for example the first one (this line is fine without option strict) m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication it occurs in this function in a class: Function Init2(ByVal bDebug As Boolean) As Boolean m_Debug = bDebug Try m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication m_acadDoc = m_AcadApp.ActiveDocument Return True Catch ex As Exception Return False End Try End Function and the variable is defined thus at the top of the class Private m_AcadApp As AcadApplication = Nothing and i have this imports line above that Imports Autodesk.AutoCAD.ApplicationServices.Application but with option strict on i get the following error and don't know how to more explicittly define the variable. error: Option Strict On disallows implicit conversions from 'Object' to 'Autodesk.AutoCAD.Interop.AcadApplication'. I'm not declaring it as object(late binding) but that's what the compiler says i'm doing how to handle this with option strict or is option strict not necessary? thanks mark |
#3
| |||
| |||
|
|
error: Option Strict On disallows implicit conversions from 'Object' to 'Autodesk.AutoCAD.Interop.AcadApplication'. I'm not declaring it as object(late binding) but that's what the compiler says i'm doing how to handle this with option strict or is option strict not necessary? |
#4
| |||
| |||
|
|
Option Strict Off is only a good when you are a real beginner coming from VB6 One reason, you have the chance that your programs run 10 times slower with VB6 off. (But also that errors are detected only at runtime) Be aware Reflection uses the same methods as are in Option Strict Off. "mp" <nospam (AT) Thanks (DOT) com> wrote in message news:i1b66c$13l$1 (AT) news (DOT) eternal-september.org... more beginner questions Is option strict recommended practice in general with vbnet? if i turn it on i get hundreds of errors for example the first one (this line is fine without option strict) m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication it occurs in this function in a class: Function Init2(ByVal bDebug As Boolean) As Boolean m_Debug = bDebug Try m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication m_acadDoc = m_AcadApp.ActiveDocument Return True Catch ex As Exception Return False End Try End Function and the variable is defined thus at the top of the class Private m_AcadApp As AcadApplication = Nothing and i have this imports line above that Imports Autodesk.AutoCAD.ApplicationServices.Application but with option strict on i get the following error and don't know how to more explicittly define the variable. error: Option Strict On disallows implicit conversions from 'Object' to 'Autodesk.AutoCAD.Interop.AcadApplication'. I'm not declaring it as object(late binding) but that's what the compiler says i'm doing how to handle this with option strict or is option strict not necessary? thanks mark |
#5
| |||
| |||
|
|
Sorry, I see now that I misunderstood your question, Can you try this one m_AcadApp = DirectCast(Autodesk.AutoCAD.ApplicationServices.Ap plication.AcadApplication,AcadApplication) Seems that the property and the type have the same name. Got this from Internet looking at C# where it cannot be done without the cast. Cor "Cor" <none (AT) none (DOT) non> wrote in message news:4c395daf$0$14128$703f8584 (AT) textnews (DOT) kpn.nl... Option Strict Off is only a good when you are a real beginner coming from VB6 One reason, you have the chance that your programs run 10 times slower with VB6 off. (But also that errors are detected only at runtime) Be aware Reflection uses the same methods as are in Option Strict Off. "mp" <nospam (AT) Thanks (DOT) com> wrote in message news:i1b66c$13l$1 (AT) news (DOT) eternal-september.org... more beginner questions Is option strict recommended practice in general with vbnet? if i turn it on i get hundreds of errors for example the first one (this line is fine without option strict) m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication it occurs in this function in a class: Function Init2(ByVal bDebug As Boolean) As Boolean m_Debug = bDebug Try m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication m_acadDoc = m_AcadApp.ActiveDocument Return True Catch ex As Exception Return False End Try End Function and the variable is defined thus at the top of the class Private m_AcadApp As AcadApplication = Nothing and i have this imports line above that Imports Autodesk.AutoCAD.ApplicationServices.Application but with option strict on i get the following error and don't know how to more explicittly define the variable. error: Option Strict On disallows implicit conversions from 'Object' to 'Autodesk.AutoCAD.Interop.AcadApplication'. I'm not declaring it as object(late binding) but that's what the compiler says i'm doing how to handle this with option strict or is option strict not necessary? thanks mark |
#6
| |||
| |||
|
|
Thanks that worked! I'm now working through the hundreds of implicit casts and converting to direct... how do I handle this one? this used to work before i turned option strict on Dim Length as Double KERF_OFFSET is a const double Dim NumberKerfs As Integer = Fix(Length / KERF_OFFSET) now i get the error: Option Strict On disallows implicit conversions from 'Double' to 'Integer'. so i tried this Dim NumberKerfs As Integer = DirectCast(Fix(Length / KERF_OFFSET), Int16) now i get the error Value of type 'Double' cannot be converted to 'Short'. I don't get it because the help on Fix says it takes a double as arg Number Required. A number of type Double or any valid numeric expression and it returns an integer my variable is declared integer and set to return value of Fix so where's the cast??? Thanks again for your help Mark "Cor" <none (AT) none (DOT) non> wrote in message news:4c39a801$0$14124$703f8584 (AT) textnews (DOT) kpn.nl... Sorry, I see now that I misunderstood your question, Can you try this one m_AcadApp = DirectCast(Autodesk.AutoCAD.ApplicationServices.Ap plication.AcadApplication,AcadApplication) Seems that the property and the type have the same name. Got this from Internet looking at C# where it cannot be done without the cast. Cor "Cor" <none (AT) none (DOT) non> wrote in message news:4c395daf$0$14128$703f8584 (AT) textnews (DOT) kpn.nl... Option Strict Off is only a good when you are a real beginner coming from VB6 One reason, you have the chance that your programs run 10 times slower with VB6 off. (But also that errors are detected only at runtime) Be aware Reflection uses the same methods as are in Option Strict Off. "mp" <nospam (AT) Thanks (DOT) com> wrote in message news:i1b66c$13l$1 (AT) news (DOT) eternal-september.org... more beginner questions Is option strict recommended practice in general with vbnet? if i turn it on i get hundreds of errors for example the first one (this line is fine without option strict) m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication it occurs in this function in a class: Function Init2(ByVal bDebug As Boolean) As Boolean m_Debug = bDebug Try m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication m_acadDoc = m_AcadApp.ActiveDocument Return True Catch ex As Exception Return False End Try End Function and the variable is defined thus at the top of the class Private m_AcadApp As AcadApplication = Nothing and i have this imports line above that Imports Autodesk.AutoCAD.ApplicationServices.Application but with option strict on i get the following error and don't know how to more explicittly define the variable. error: Option Strict On disallows implicit conversions from 'Object' to 'Autodesk.AutoCAD.Interop.AcadApplication'. I'm not declaring it as object(late binding) but that's what the compiler says i'm doing how to handle this with option strict or is option strict not necessary? thanks mark |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |