Hello, I am trying to make a simple program that generates random musical notes, and for the most part, I'm done, but at the end, I'm left with an array full of notes that I'm not sure what to do with. I want to output the notes to a label, and the array length is variable. I really have no idea what to do. I am trying to display the array OutputNotes:
VB.NET:
Public Class Form1
Private Sub DoneButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoneButton.Click
Randomize()
Dim NoteString As String() = {"a", "a#", "b", "c", "c#", "d", "d#", "e", "f", "f#", "g", "g#"}
Dim NumberOfNotes As Integer
Dim StartNote As Integer
'determine starting note
If RandomNoteCheckBox.Checked = True Then
StartNote = Int((11 - 0 + 1) * Rnd())
Else
StartNote = Array.BinarySearch(NoteString, StartingNoteTextBox.Text)
End If
'determine # of notes in sequence
If RandomNumberCheckBox.Checked = True Then
NumberOfNotes = Int((30 - 5 + 1) * Rnd())
Else
NumberOfNotes = Integer.Parse(SequenceTextBox.Text)
End If
Dim OutputNotes(NumberOfNotes - 1) As String
Dim i As Integer = 0
'generate notes
Do Until i = NumberOfNotes
OutputNotes(i) = NoteString(StartNote)
i += 1
StartNote = Int((11 - 0 + 1) * Rnd())
Loop
'output notes
???????
End Sub
End Class
Last edited: