Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am accustomed to vb6 so I need to learn how to program in vb.net so I can code music or sound effects for a hobby.

What I have tried:

I tried to use my vb6 code but it is not quite the same as vb.net 2017. I just need a sample that doesn't use music files just type the values in code.
Posted
Updated 1-Dec-19 1:53am

It's not simple! Have a look here: Virtual Piano in C#[^] - it uses a single WAV file which is programatically altered to change the frequency, which for music generation is probably a better "sound" than a "pure" tone.
The code is in C#, but it's pretty obvious, and online converters may help you convert it to VB for .NET

Though I'd strongly recommend you dump VB altogether, and switch to C#. VB6 is very, very different from "modern" VB and you will have a lot of VB6 habits which will not help you at all to produce "good" VB code. Switching to C# would "break the connection" to those bad habits, and hopefully make your long-term coding easier. An experienced coder should be able to pick up C# in between an afternoon and a week (depending on how experienced you are) - iutr;s teh .NET framework that takes the time to learn (and you need that for both "modern" VB and C# development).

There is a free book here: https://www.robmiles.com/c-yellow-book[^] which covers it well.
 
Share this answer
 
Comments
Maciej Los 1-Dec-19 7:34am    
5!
You probably can do it with the Naudio library: GitHub - naudio/NAudio: Audio and MIDI library for .NET[^]
I tried to find a VB.NET example for you, but could not find one, most examples are in C#.
 
Share this answer
 
Comments
Maciej Los 1-Dec-19 7:34am    
5!
You can play a tone at any frequency with the following:
VB
Dim freq As Integer = Integer.Parse(txtFrequency.Text)
Dim duration As Integer = Integer.Parse(txtDuration.Text)

System.Console.Beep(freq, duration)
 
Share this answer
 
Comments
Maciej Los 1-Dec-19 7:31am    
5ed!
Short And To The Point!
If you're interested in music notation, please read this: Music Notation in .NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900