我看到这篇文章:
错别道......请使用严格和明确的选项...在一个软件开发项目中,我作为顾问,他们在各地都得到了大量的错误......结果发现开发人员无法拼写并且会声明拼写错误的变量.没什么大不了的,直到你为它分配一个值时使用正确的拼写......并且你有明确的选项.哎哟......"
什么是Option Strict和Option Explicit呢?我已经google了它但无法得到这个想法(因为它主要是Visual Basic,我正在做PHP).
我有以下代码返回wmi信息(未知数组)
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
Run Code Online (Sandbox Code Playgroud)
函数ConvertArray将其转换为字符串值.
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 - 1
If TypeOf myarray(tel) Is UInt16 Then
res = res + "[" …Run Code Online (Sandbox Code Playgroud)