I like to pass reference types on the initializer of new forms. This lets them share variables.
Form2 f2 = new Form2();
f2.Show();using (FormSoundCard frm = new FormSoundCard())
{
frm.ShowDialog();
Console.WriteLine(frm.deviceNumber);
}private void button2_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
this.Hide();
}Edit Program.cs
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form2());
}