vb.net - Visual Basic generate random number -
i new coding , want make simple program moves windows random location on desktop. right code this:
me.location = new point(27, 55) me.location = new point(502, 624) me.location = new point(858, 477) me.location = new point(564, 50) me.location = new point(898, 41) me.location = new point(468, 944) me.location = new point(417, 7) me.location = new point(841, 697) me.location = new point(953, 438)
i had put in code myself never random , repeat itself. how make numbers random number?
first declare variable in scope of class:
dim rnd new random
then put code in whatever event want use set window random position:
me.location = new point(rnd.next(0, my.computer.screen.workingarea.width - me.width), rnd.next(0, my.computer.screen.workingarea.height - me.height))
this make sure window stay within bounds of screen when put new random position.
Comments
Post a Comment