Thursday, 15 March 2012

vb.net - Visual Basic Randomizing numbers and setting them to a song -



vb.net - Visual Basic Randomizing numbers and setting them to a song -

can help me programme in visual basic. need random number generator take random numbers , play songs based on numbers. cant remember how set number each song. know need kind of if statement. generate random songs when button clicked. know how this? need whole code including dim 1 integer. have far, know wrong. in advance

public class nametheartist private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load dim number integer dim rndnumber random rndnumber = new random number = rndnumber.next(1, 10) dim 1 integer dim 2 integer dim 3 integer dim 4 integer dim 6 integer dim 7 integer dim 8 integer dim 9 integer dim 10 integer dim 5 integer end sub private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click public function getrandom(byval min integer, byval max integer) integer dim generator system.random = new system.random() homecoming generator.next(1, 10) end function public function play(byval num integer) if num = 1 my.computer.audio.play(my.resources.black_widow, audioplaymode.background) threading.thread.sleep(5000) homecoming true elseif num = 2 my.computer.audio.play(my.resources.music2, audioplaymode.background) threading.thread.sleep(5000) homecoming true end if if number = 1 my.computer.audio.play(my.resources.black_widow, audioplaymode.background) my.computer.audio.play(my.resources.all_about_that_bass, audioplaymode.background) my.computer.audio.play(my.resources.trumpets, audioplaymode.background) my.computer.audio.play(my.resources.love_story, audioplaymode.background) homecoming false end function end sub private sub textbox1_textchanged(byval sender system.object, byval e system.eventargs) handles textbox1.textchanged end sub end class

i guess looking this:

public function play(byval num integer) boolean select case num case 1 my.computer.audio.play(my.resources.black_widow, audioplaymode.background) threading.thread.sleep(5000) homecoming true case 2 my.computer.audio.play(my.resources.music2, audioplaymode.background) threading.thread.sleep(5000) homecoming true case 3 my.computer.audio.play(my.resources.whatever, audioplaymode.background) threading.thread.sleep(5000) homecoming true case n my.computer.audio.play(my.resources.song_n, audioplaymode.background) threading.thread.sleep(5000) homecoming true end select homecoming false end function

create case every number/song got. dont see integers have declared for. might remove these clean code.

vb.net

No comments:

Post a Comment