• Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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;
}



Returns the memory address:
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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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~

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement