我是 VBA 新手,想知道是否可以将以下声明和赋值转换为一行:
Dim clientToTest As String clientToTest = clientsToTest(i)
或者
Dim clientString As Variant clientString = Split(clientToTest)
不幸的是,VBA 中没有速记,:如果您希望将连续字符放在一行中以提高可读性,那么您将得到的最接近的是纯视觉的东西;
:
Dim clientToTest As String: clientToTest = clientsToTest(i) Dim clientString As Variant: clientString = Split(clientToTest)
提示(其他答案/评论的摘要):也适用于对象(Excel 2010):
Dim ws As Worksheet: Set ws = ActiveWorkbook.Worksheets("Sheet1") Dim ws2 As New Worksheet: ws2.Name = "test"