web stats

How to Create Beep Tunes Using VB

 


Using VB, the internal speaker in your PC, and a couple lines of code, you can create a very basic, yet entertaining tune. To start off, boot up VB and create a new application.

Place a Button onto the form, like this…

Double click it, and enter the following line of code…

Basically, the Console.Beep part is telling the program that it’s going to beep. The 2 values next to it are the pitch of the note, and the duration it will be played for. A quick search on google brings up this list of note pitches and their corresponding values. I’m not sure if they are correct, but whatever.

GbelowC = 196
A = 220
Asharp = 233
B = 247
C = 262
Csharp = 277
D = 294
Dsharp = 311
E = 330
F = 349
Fsharp = 370
G = 392
Gsharp = 415

Next, add another line of similar code below it, until you have a tune going on…

Finally, when you wish to test your tune, hit F5 to debug the application and you can test it out. If there’s any errors in your code, they will be brought to your attention with the debug. If not, then your application will load up. All you gotta do now is click the button!

Have fun!

Discuss  http://www.totse.info/bbs/showthread.php?t=4898

Leave a Reply