tags:

views:

46

answers:

2

I'm new to VBA and want to know if I can convert the following declaration and assignment into one line:

Dim clientToTest As String
clientToTest = clientsToTest(i)

or

Dim clientString As Variant
clientString = Split(clientToTest)
+3  A: 

You can sort-of do that with objects, as in the following.

Dim w As New Widget

But not with strings or variants.

John M Gant
+4  A: 

There is no shorthand in VBA unfortunately, The closest you will get is a purely visual thing using the : continuation character if you want it on one line for readability;

Dim clientToTest As String:  clientToTest = clientsToTest(i)
Dim clientString As Variant: clientString = Split(clientToTest)
Alex K.
+1, I remember Microsoft suggesting during the buildup to .NET that VB6 developers start doing this to get ourselves ready for VB.NET.
John M Gant