Variable deklarieren
07.04.2022 07:28:02
Antonio
Ich versuche eine Variable im Code zu deklarieren und zuweisen:
Sub BassProc()
KillTimer 0&, hTimerBas: hTimerBas = 0 ' Bass-Timer löschen
With ThisWorkbook.Sheets("Midi")
Do
Dim iVoiceNum As Integer
Dim iVolume As Integer
iVoiceNum = .Cells(2, 15) 'Variable Instrument
iVolume = .Cells(3, 15) 'Variable Volume
iZeileBas = iZeileBas + 1
If iZeileBas > .Cells(.Rows.Count, "K").End(xlUp).Row Then
If hTimerBeg = 0 Then midiOutClose hMidiOut: hMidiOut = 0
Exit Sub
End If
If Val(.Cells(iZeileBas, 13).Value) > 0 Then Exit Do
Loop
If iZeileBas > 2 Then _
PlayMIDI .Cells(iZeileBas - 1, 11).Value, .Cells(iZeileBas - 1, 12).Value, 0
PlayMIDI iVoiceNum, .Cells(iZeileBas, 12).Value, iVolume
If cTimerBas = 0 Then cTimerBas = (Timer * 1000)
cTimerBas = cTimerBas + .Cells(iZeileBas, 13).Value
hTimerBas = SetTimer(0&, 0&, cTimerBas - (Timer * 1000), AddressOf BassProc)
End With
End Sub
Sub PlayMIDI(iVoiceNum As Integer, vNoteNum As Variant, Optional iVolume As Integer = 127)
Dim i As Integer, vArr As Variant, iFound As Long
If hMidiOut = 0 Then Exit Sub ' Kein Handle=>raus
If iVoiceNum > 0 Then _
midiOutShortMsg hMidiOut, (256 * iVoiceNum) + 192 ' Instrument wählen
vArr = Split(vNoteNum, ",") ' Noten zusamenstellen
On Error Resume Next
For i = 0 To UBound(vArr)
If Val(vArr(i)) = 0 Then
With ThisWorkbook.Sheets("Midi")
iFound = 0
iFound = WorksheetFunction.Match(vArr(i), .Columns(35), 0)
If iFound > 0 Then
vArr(i) = .Cells(iFound, 34).Value
End If
End With
End If
midiOutShortMsg hMidiOut, RGB(144, vArr(i), iVolume) '144 = h90
Next i
DoEvents
End Sub
aber funzt nicht, habe sie vielleicht an der falsche Stelle?Soll evtll. im Sub PLAYMIDI sein?
Ich bitte um ein wenig Hilfe
Vielen Dank im Voraus
LG Antonio
Anzeige