Jump to content

Having troubles with RS Calculator


runesmithie

Recommended Posts

Hey, I recently got permission to make a calculator for Runescape in my Visual Basic class...

 

 

 

Now I want to be efficient and not have something like

 

 

 

If single.parse(me.uiLevelTextBox.text) = 70 Then



exp=823662

 

 

 

 

 

 

 

But how would you convert this to code in VB? I saw his Javascript code and the Python code, but when I implement something similar in VB it always comes out off

 

 

 

 

 

 

 

Equation:

 

 

 

http://maddogcarter.com/phil/runescape/equation.gif

 

 

 

 

 

 

 

Javascript:

 

 

 

document.close();



document.open();



document.writeln('Begin JavaScript output:');



document.writeln('');







points = 0;



output = 0;



minlevel = 2;		// first level to display



maxlevel = 500;		// last level to display







for (lvl = 1; lvl <= maxlevel; lvl++)



{



points += Math.floor(lvl + 300 * Math.pow(2, lvl / 7.));



if (lvl >= minlevel)



	document.writeln('Level ' + (lvl) + ' - ' + output + ' xp');



output = Math.floor(points / 4);



}







document.writeln('');



document.close();

 

 

 

 

 

 

 

Python:

 

 

 

points = 0



for level in range(1,100):



diff = int(level + 300 * math.pow(2, float(level)/7) )



points += diff



str = "Level %d = %d" % (level + 1, points / 4)



print str

smithie3.jpg

I just posted something! ^_^ to the terrorist...er... kirbybeam.
Link to comment
Share on other sites

Hey, I recently got permission to make a calculator for Runescape in my Visual Basic class...

 

 

 

Now I want to be efficient and not have something like

 

 

 

If single.parse(me.uiLevelTextBox.text) = 70 Then



exp=823662

 

 

 

 

 

 

 

But how would you convert this to code in VB? I saw his Javascript code and the Python code, but when I implement something similar in VB it always comes out off

 

 

 

 

 

 

 

Equation:

 

 

 

http://maddogcarter.com/phil/runescape/equation.gif

 

 

 

 

 

 

 

Javascript:

 

 

 

document.close();

 

 

 

document.open();

 

 

 

document.writeln(Begin JavaScript output:);

 

 

 

document.writeln(<PRE>);

 

 

 

 

 

 

 

points = 0;

 

 

 

output = 0;

 

 

 

minlevel = 2; // first level to display

 

 

 

maxlevel = 500; // last level to display

 

 

 

 

 

 

 

for (lvl = 1; lvl <= maxlevel; lvl++)

 

 

 

{

 

 

 

points += Math.floor(lvl + 300 * Math.pow(2, lvl / 7.));

 

 

 

if (lvl >= minlevel)

 

 

 

document.writeln(Level + (lvl) + - + output + xp);

 

 

 

output = Math.floor(points / 4);

 

 

 

}

 

 

 

 

 

 

 

document.writeln(</PRE>);

 

 

 

document.close();

 

 

 

 

 

 

 

Python:

 

 

 

points = 0



for level in range(1,100):



diff = int(level + 300 * math.pow(2, float(level)/7) )



points += diff



str = "Level %d = %d" % (level + 1, points / 4)



print str

 

 

 

You know, it's actually way easier if you just define an Array with all the elements set. But should you really want to use that formula:

 

 

 

 

 

 

 

Dim points = 0



Dim output = 0



Dim minlevel = 2



Dim maxlevel = 150



Dim lvl As Integer



Dim outputStr As String







For lvl = 1 To maxlevel



   points = points + Math.Floor(lvl + 300 * Math.Pow(2, (lvl / 7)))



   If lvl >= minlevel Then



        outputStr = outputStr + vbNewLine + "Level " + lvl + ": " + output + " xp"



   End If



   output = Math.Floor(points / 4)



Next







' Do whatever you want with the outputStr here.



 

 

 

 

 

 

 

 

 

 

 

PS: I used a Firefox extension to colorize your javascript source. However pretty it looks, it seems to have killed the quotes. I'll mail the author to have that corrected :P

Link to comment
Share on other sites

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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.