我已经学习了很多浏览C#的隐藏功能,当我找不到类似于VB.NET的东西时,我感到很惊讶.
那么它的一些隐藏或鲜为人知的特征是什么?
我从这个答案中获取了以下工作代码:
Option Compare Binary
Option Explicit On
Option Infer On
Option Strict Off
Imports Microsoft.Office.Interop
Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Friend Module Module1
Private Declare Function GetDesktopWindow Lib "user32" () As IntPtr
Private Declare Function EnumChildWindows Lib "user32.dll" (ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowsProc, ByVal lParam As IntPtr) As Boolean
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hWnd As IntPtr, ByVal lpClassName As String, ByVal nMaxCount As Integer) As Integer
Private Delegate Function EnumWindowsProc(ByVal hwnd As …Run Code Online (Sandbox Code Playgroud) 我来自面向对象的背景.为什么"Test"(注意引号)显示在此代码片段中(在消息框中).我期望逻辑测试:'如果Test ="True"'返回False,因为变体包含布尔值而不是字符串.因此,我不希望消息框出现,但它确实:
Dim Test As Variant
Test = True
If Test = "True" Then //line 5
MsgBox ("Test")
End If
Run Code Online (Sandbox Code Playgroud)