Dim a,b As Integer
Dim a2,b2 as Integer
a=2
b=3
a2=(a)
b2=(b)
a2 + b2 calculate 5 ??
How can i work with pointer ?
in dbase iV it was possible with a syntax like this..
&a2. give 2
Please Help ....
Printable View
Dim a,b As Integer
Dim a2,b2 as Integer
a=2
b=3
a2=(a)
b2=(b)
a2 + b2 calculate 5 ??
How can i work with pointer ?
in dbase iV it was possible with a syntax like this..
&a2. give 2
Please Help ....
First of all, a common mistake:
This is what happens with this:Code:Dim a, b as integer
Dim a2, b2 as integer
a and a2 are declared as Variants
b and b2 are declared as Integers
Would be the correct alternative.Code:Dim a as Integer, b as integer
Dim a2 as integer, b2 as integer
Then, about your problem.
As far as i know, VB does not support Pointers. The only sort of Pointer thing, is the AddressOf function, but you shouldn't ask me about that. I don't know how it works. It only returns the addresses of functions. (I think) :(
Could someone tell if it is possible.
What do you want to do?
I don't know why you want to use a pointer.
This sets the value of a2 equal to the value of a, and b2 equal to b.Code:a2 = (a)
b2 = (b)
will set Label1's caption to:Code:Label1.Caption = a & " " & a2 & " " & b & " " & b2
2 2 3 3
so
would set the Caption to:Code:Label1.Caption = a2 + b2
5
I don't understand what you want.
A pointer in C works like this:
a = 2
b = (a)
OK now b = 2 (fine).
But if you do this.
a = 5
Without anything else b is now 5.
A pointer works like a "=A1" in excel if you change "A1" the value of the current cell will change automatically.
I think in VB 5.0 was an undocumented function farptr but AFAIK it doesn't still exist. But you can set something like a pointer. However, it works only with classes so you can't point to an integer.
it doens't matter wich var, A or B, you modify. They're always the same. It's like if A and B both points to the 'real' value ;).Code:Dim A as new TestClass 'Only a test, class doesn't really exist
Dim B as TestClass 'This will be the pointer
A.SetX 15
Set B = A 'B points to A
Print B.GetX 'Returns x of A
PS:
Don't worry about pointers in VB, code in C if you want to use pointers ;). For example if you call a function, VB automatically just transfers the pointers (You have to declare as ByVal explicitely to transfer *not* the pointer).