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!

Adding percents to variables?

Status
Not open for further replies.

kevcoles

Programmer
Feb 19, 2004
2
CA
If you have an integer variable, how can you change the variable, so the number is a percentage?

Thanks
 
Please clarify what you want.
Kind of "We have variable X holding value 105; and we want..."
As for now I can't get what exactly you want to do.
 
wouldnt this work:

dim n as integer
dim z as long
n = 50 'integer that you want to change

z = n 'you just put the integer into a
'percentage variable

im not sure if this example will work so dont trust me.
if im wrong about this then would somebody who nos better then me please tell me my mistake
 
There is no way to make something an actual percentage ie. Print z would display "50%". What you can do, however, is possible to go z=n/100 to get .5, which you could then use as a percentage, just like someone above said.

Remember, a huge part of programming is telling the computer how to do mundane things like display percentages, draw graphs or numbers, or add numbers together. You have to tell the computer everything, minus a couple things that the compiler handles for you. Since it seems this is probably for your game, could I again recommend playing around more with syntax and algorithms before tackling a full-scale RPG? Speaking from experience, I started a little higher than you seem to be when I stated coding the JRPG engine ( and the result has been years of problems that could have been solved by anyone of mediocre experience. Try setting up an action game to try various techniques on before you run full tilt into the single hardest genre to code, script, and otherwise create. You'll thank yourself later when you're coding away, hit a simple problem, and know the solution already from code you've already written. :)
 
do you mean change the variable into a decimel like 5.267 or a percenage like 37%.
 
TO kevcoles,

I've noticed you came back four other times; but you didn't participate in your own post.

Have you found your answer?
[ol][li]If not, you should respond to the above inquiries.[/li]

[li]If yes, you should post something here so that we all know this post is done.[/li]
[/ol]

Please let us know.
--MiggyD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top