m33tmn Posted November 24, 2005 Share Posted November 24, 2005 Hi all, i was hoping someone here could help me, i'm very unexperienced with ASP but i need to change something in a .aspx file. i want an object to be displayed at a random position. generating random numbers got me completely stuck. i currently have: <DIV STYLE="position:absolute; LEFT: 145px; TOP: 25pt"> i would like to change 145 and 25 to 2 random (different) numbers between 5 and 600. could anyone help me with that? if you know asp it can't be hard thanks, marc Link to comment Share on other sites More sharing options...
Jerome Posted November 24, 2005 Share Posted November 24, 2005 HiHere you have a function that receives two parameters (highest and lowest number), the "Do Untill" loop provides you a random number between those two parameters, then you just have to put those values into your top and left variables. <%Function RandomNumber(intLowestNumber,intHighestNumber) Do Until (RandomNumber >= intLowestNumber) And (RandomNumber <= intHighestNumber) Randomize RandomNumber = Int(Rnd * intHighestNumber) + 1 LoopEnd FunctionleftRndNumber = RandomNumber(5,600)topRndNumber = RandomNumber(5,600)%> Happy programming Link to comment Share on other sites More sharing options...
m33tmn Posted November 28, 2005 Author Share Posted November 28, 2005 lol and how can i possibly add those variables (i think LeftRndNumber and TopndNumber are) to the values? hehe i truely ###### at asp i haven't really started.. basicly because asp.net is a sloww website... Link to comment Share on other sites More sharing options...
Jerome Posted November 28, 2005 Share Posted November 28, 2005 Ok, just call the function where you need to use your random number : <DIV STYLE="position:absolute; LEFT: <%=RandomNumber(5,600)%>px; TOP: <%=RandomNumber(5,600)%>pt">Hello</div> Link to comment Share on other sites More sharing options...
m33tmn Posted November 29, 2005 Author Share Posted November 29, 2005 and it still gives me errors..... <%Function RandomNumber(intLowestNumber,intHighestNumber) Do Until (RandomNumber >= intLowestNumber) And (RandomNumber <= intHighestNumber) Randomize RandomNumber = Int(Rnd * intHighestNumber) + 1LoopEnd Function%><DIV STYLE="position:absolute; LEFT: <% =RandomNumber(5,600) %>px; TOP: <% =RandomNumber(5,600) %>pt">Hello</div> doesn't work.... server error in '/' application.... blahblah i'm sure you know it :)thanks, marc Link to comment Share on other sites More sharing options...
Jerome Posted December 1, 2005 Share Posted December 1, 2005 ok, post your code and the error message! Link to comment Share on other sites More sharing options...
m33tmn Posted December 1, 2005 Author Share Posted December 1, 2005 Server Error in '/' Application.--------------------------------------------------------------------------------Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed.Source Error: Line 3: <DIV align="center"><STRONG><FONT face="Verdana" color="#ffffff" size="4">National Prison</FONT></STRONG>Line 4: <%Line 5: Function RandomNumber(intLowestNumber,intHighestNumber)Line 6: Do Until (RandomNumber >= intLowestNumber) And (RandomNumber <= intHighestNumber)Line 7: Randomize Source File: c:\inetpub\wwwroot\X.aspx Line: 5detailed information also available, if needed...thanks, marc Link to comment Share on other sites More sharing options...
Jerome Posted December 7, 2005 Share Posted December 7, 2005 Ok, but this is a question for the asp.net forum no? Link to comment Share on other sites More sharing options...
m33tmn Posted December 7, 2005 Author Share Posted December 7, 2005 Ok, but this is a question for the asp.net forum no?<{POST_SNAPBACK}> i had the choice between the .net forum and the asp forum, i chose asp... 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