option-explicit

VBScript Option Explicit line order (in relation to libraries)

醉酒当歌 提交于 2019-12-24 08:47:54
问题 I have a fairly large VB Script project in which the primary script "includes" a number of "libraries" using the standard trick of reading file contents and running ExecuteGlobal on them. Some of the libraries are pretty vast and written by various third parties. I want to use Option Explicit . If I make it the first line executed, however, some of those libraries blow up. But, if I move the directive to below my list of includes, I encounter the error Expected Statement on that line. Even

Option Strict On disallows late binding with system.array

試著忘記壹切 提交于 2019-12-22 10:06:12
问题 I have the following code which return wmi information (unknown array) For Each objMgmt In oquery.Get() For Each theproperty In objMgmt.Properties If (TypeOf objMgmt(theproperty.Name) Is System.Array) Then myrow(theproperty.Name) = ConvertArray(CType(objMgmt(theproperty.Name), Array)).Trim end if next next Function ConvertArray converts this to a string value. Function ConvertArray(ByVal myarray As System.Array) As String Dim tel As Integer Dim res As String = "" If myarray.Length = 0 Then

Option Strict On disallows late binding with system.array

一笑奈何 提交于 2019-12-05 23:06:28
I have the following code which return wmi information (unknown array) For Each objMgmt In oquery.Get() For Each theproperty In objMgmt.Properties If (TypeOf objMgmt(theproperty.Name) Is System.Array) Then myrow(theproperty.Name) = ConvertArray(CType(objMgmt(theproperty.Name), Array)).Trim end if next next Function ConvertArray converts this to a string value. Function ConvertArray(ByVal myarray As System.Array) As String Dim tel As Integer Dim res As String = "" If myarray.Length = 0 Then Return "" End If If myarray.Length = 1 Then res = myarray(0).ToString Else For tel = 0 To myarray.Length

What do Option Strict and Option Explicit do?

回眸只為那壹抹淺笑 提交于 2019-11-25 22:57:47
问题 I saw this post: Typos… Just use option strict and explicit please.. during one software development project, which I was on as a consultant, they were getting ridiculous amounts of errors everywhere… turned out the developer couldn’t spell and would declare variables with incorrect spelling.. no big deal, until you use the correct spelling when you’re assigning a value to it… and you had option explicit off. Ouch to them…\" What is Option Strict and Option Explicit anyway? I have googled it