there is the option to do this in vb.net
Dim a, b, c As Single, x, y As Double, i As Integer
also you can do
Dim myString = String.empty
Is there a way to initialize and assign multiple variables like the first example but using the assignment as the second one?
I tested it in VS 2008, but I don't think that the Syntax of the Dim statement changed since. You will have to specify the type for each variable, if you initialize them
Dim a As Single = 1, b As Single = 2, x As Double = 5.5, y As Double = 7.5
Or you can let VB infer the type and use type characters (here !
for Single
):
Dim a = 1!, b = 2!, c = 3!, x = 5.5, y = 7.5, i = 100
By hovering with the cursor over the variables in VS you will see that the types are inferred correctly as Single
, Double
and Integer
.
You could also use F
for single. See: Constant and Literal Data Types (Visual Basic)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With