|
-
Feb 23rd, 2000, 07:13 PM
#1
Thread Starter
New Member
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 ....
-
Feb 23rd, 2000, 08:34 PM
#2
Fanatic Member
First of all, a common mistake:
Code:
Dim a, b as integer
Dim a2, b2 as integer
This is what happens with this:
a and a2 are declared as Variants
b and b2 are declared as Integers
Code:
Dim a as Integer, b as integer
Dim a2 as integer, b2 as integer
Would be the correct alternative.
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)
r0ach™
Don't forget to rate the post
-
Feb 23rd, 2000, 09:56 PM
#3
Addicted Member
Could someone tell if it is possible.
-
Feb 23rd, 2000, 10:13 PM
#4
Fanatic Member
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:
Label1.Caption = a & " " & a2 & " " & b & " " & b2
will set Label1's caption to:
2 2 3 3
so
Code:
Label1.Caption = a2 + b2
would set the Caption to:
5
I don't understand what you want.
r0ach™
Don't forget to rate the post
-
Feb 24th, 2000, 08:58 PM
#5
Addicted Member
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.
-
Feb 24th, 2000, 10:16 PM
#6
PowerPoster
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.
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
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 .
-
Feb 24th, 2000, 10:27 PM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|