Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User defined types and passing between subs.

Status
Not open for further replies.

KingofSnake

Programmer
Jul 25, 2000
73
US
I have a type that looks like this:<br><br>TYPE playertype<br>&nbsp;&nbsp;&nbsp;cash AS INTEGER<br>&nbsp;&nbsp;&nbsp;hp AS INTEGER<br>&nbsp;&nbsp;&nbsp;etc as INTEGER<br>END TYPE<br><br>DIM player AS playertype<br><br>I would like to pass these values (like cash.player, hp.player) between subs.&nbsp;&nbsp;Currently I have a COMMON SHARED statement, and I have to list every value one by one.&nbsp;&nbsp;Isn't there something I can put in the COMMON SHARED statement that will make as of these be able to pass thru subs?&nbsp;&nbsp;Or is there something else I have to do (I don't want to declare something in each sub argument thingy.)
 
Try this out:<br><br>before your program starts declare your variable like this:<br><br>DIM SHARED player()<br><br>and you can use player.cash, player.hp, player.etc it in any sub/function without the COMMON SHARED statement.<br><br>Hope I helped :D <p> Alex<br><a href=mailto:pizzapz@libero.it>pizzapz@libero.it</a><br><a href= > </a><br>*** Q(uick)BASIC RULEZ! :D***
 
Oh man!&nbsp;&nbsp;I figured out that I was messing up on the varaibles (I put in hp.player when it shoulda been player.hp).&nbsp;&nbsp;I had to change all the vars. in my program!&nbsp;&nbsp;Don't you hate it when a small mistake will stump you for hours on end?&nbsp;&nbsp;Then I DIM SHARED player AS playertype.&nbsp;&nbsp;But thanks PZ for making me realize my stupid mistake :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top