runesmithie Posted May 16, 2005 Share Posted May 16, 2005 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 I just posted something! ^_^ to the terrorist...er... kirbybeam. Link to comment Share on other sites More sharing options...
Hannibal Posted May 17, 2005 Share Posted May 17, 2005 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 More sharing options...
runesmithie Posted May 17, 2005 Author Share Posted May 17, 2005 We haven't gotten into arrays yet :\ *skips ahead in book a little* thanks... for some reason I forgot to do level+300 >.< I just posted something! ^_^ to the terrorist...er... kirbybeam. Link to comment Share on other sites More sharing options...
runesmithie Posted May 18, 2005 Author Share Posted May 18, 2005 Ok, I have an array set, but I'm missing a level here :P I hope to have that fixed soon, but 199 levels is a lot to go through :| I just posted something! ^_^ to the terrorist...er... kirbybeam. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now