Sign in to follow this  

Fighting with pointers

This topic is 4746 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
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
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

This topic is 4746 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this