# Fighting with pointers

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all I'm having some trouble with pointers, and it's annoying the heck out of me. I'm creating a DLL in C++ and then using the calls in VB. This is a small example to return the random value of 54, for vb to put in a textbox. Working Code:
int ReturnValue(){
return 54;
}


int ReturnValue(){
int ret=54;
return ret;
}


Call from VB:
public declare function ReturnValue lib "test.dll"() as long
sub Main()
Msgbox ReturnValue
end sub

This has been bugging me for a day now, so i would appreciate any help you could give (possibly alternate methods) Thanks ~zix~ EDIT: hate UBB

##### Share on other sites
Your two code samples are equivalent. In both cases you are returning a value (int) not an address (and returning the address of a local variable is a bad idea anyway).

##### Share on other sites
They are equivilent, yes, but the second one doesnt work.

Can you see why it's bothering me?

~zix~

EDIT: I know it's an address because it returns a somewhat random number each time... in the millions.

##### Share on other sites
how is the second one not working? are you expecting it to be a pointer, which it is most certainly not? and just for clarity, at no point in either of those functions are you doing anything with pointers. please post the code you are using to test those functions, that is most likely where the error lies.

-me

##### Share on other sites
Maybe i'm just being stupid...
I think it is my code not the pointers, one sec, let me see if i can find the problem

##### Share on other sites
It was my stupid mistake, but thanks for trying to help...

It was here:
ret+=(ny*ZoneWidth+x)*MAXOBJ;
and it's suppose to be
ret+=(ny*ZoneWidth+nx)*MAXOBJ;

(Not that that means anything to you guys)

Thanks anyway
~zix~