T Troberg Well-Known Member Licensed User Longtime User Jun 12, 2015 #1 I've seen two variants of assigning initial value to variables: B4X: Dim x as int = 1 Dim x = 1 as int Are these just two ways of doing the same thing, or is there any difference?
I've seen two variants of assigning initial value to variables: B4X: Dim x as int = 1 Dim x = 1 as int Are these just two ways of doing the same thing, or is there any difference?
EnriqueGonzalez Well-Known Member Licensed User Longtime User Jun 12, 2015 #3 Being VB an inline programming lenguage, i think the compiler reads the whole line before translating it. the later is most used for several variables declarations B4X: dim x = 1, z = 2 as int Upvote 0
Being VB an inline programming lenguage, i think the compiler reads the whole line before translating it. the later is most used for several variables declarations B4X: dim x = 1, z = 2 as int
T Troberg Well-Known Member Licensed User Longtime User Jun 13, 2015 #4 Ah, I never thought of that option. I guess I'm to stuck in VB, where: Dim a, b as int means that a is a variant and b is an int. I just wanted to ask, to make sure that it didn't do anything that just looked the same, such as: Dim x = 1 as int would evaluate as: x casted to object 1 casted to int x becoming an int as it was assigned 1 Upvote 0
Ah, I never thought of that option. I guess I'm to stuck in VB, where: Dim a, b as int means that a is a variant and b is an int. I just wanted to ask, to make sure that it didn't do anything that just looked the same, such as: Dim x = 1 as int would evaluate as: x casted to object 1 casted to int x becoming an int as it was assigned 1
EnriqueGonzalez Well-Known Member Licensed User Longtime User Jun 13, 2015 #5 Vb is the same for multi declaration, in your first example both a and b would be declared as int https://msdn.microsoft.com/en-us/library/865x40k4.aspx For the second one, I honestly don't know Upvote 0
Vb is the same for multi declaration, in your first example both a and b would be declared as int https://msdn.microsoft.com/en-us/library/865x40k4.aspx For the second one, I honestly don't know
T Troberg Well-Known Member Licensed User Longtime User Jun 13, 2015 #6 VB.Net, yes, but in VB6, a would be a variant. Upvote 0
LucaMs Expert Licensed User Longtime User Jun 13, 2015 #7 Troberg said: I've seen two variants of assigning initial value to variables: B4X: Dim x as int = 1 Dim x = 1 as int Are these just two ways of doing the same thing, or is there any difference? Click to expand... If you use the second version, could you have: dim x = a * 10 + 5 / floor(c).... As Int <---- murderess If so, it would be like a thriller: you can discover the murderess (type) only in the final I definitely prefer the first. Upvote 0
Troberg said: I've seen two variants of assigning initial value to variables: B4X: Dim x as int = 1 Dim x = 1 as int Are these just two ways of doing the same thing, or is there any difference? Click to expand... If you use the second version, could you have: dim x = a * 10 + 5 / floor(c).... As Int <---- murderess If so, it would be like a thriller: you can discover the murderess (type) only in the final I definitely prefer the first.
T Troberg Well-Known Member Licensed User Longtime User Jun 13, 2015 #8 Good point. I also use the first, mostly out of habit. Upvote 0