Hallo Leute
Ich brauche wieder mal Hilfe. In meinem Projekt habe ich eine Module:
Option Explicit
Public lngaktPosMP3 As Long, lngLaengeMP3 As Long
Public bolPause As Boolean
Public stgDatei As String
Public lngSec As Long, lngMin As Long, lngHours As Long
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpszCommand As String, ByVal lpszReturnString As String, _
ByVal cchReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function GetShortPathNameA Lib "kernel32" _
(ByVal lpszLongPath As String, ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Public Sub playMP3(ByVal Dateiname As String)
Dim Retval As String, Buffer As String * 256
Retval = GetShortPathNameA(Dateiname, Buffer, Len(Buffer))
Dateiname = Left$(Buffer, Retval)
If lngaktPosMP3 And lngLaengeMP3 <> 0 Then
stopMP3 'Lied stoppen
End If
If mciSendString("open " & Dateiname & " type MPEGVideo alias MP3Name" _
, 0, 0, 0) = 0 Then
mciSendString "play MP3Name from 0", 0, 0, 0 'Datei abspielen
bolPause = False
Form1.cmdBreak.Caption = "Break"
End If
End Sub
Public Sub breakMP3()
With Form1
If bolPause = False Then
mciSendString "pause MP3Name", 0, 0, 0
bolPause = True
.cmdBreak.Caption = "More"
.lblZustand.Caption = "Break"
.Timer1.Enabled = False
Else
mciSendString "resume MP3Name", 0, 0, 0
bolPause = False
.Timer1.Enabled = True
.cmdBreak.Caption = "Break"
End If
End With
End Sub
Public Sub stopMP3()
mciSendString "stop MP3Name", 0, 0, 0 'Datei stoppen
mciSendString "close MP3Name", 0, 0, 0 'Datei schließen
End Sub
Public Sub aktPosMP3()
lngaktPosMP3 = Abfrage("status MP3Name position")
Form1.lblaktPos.Caption = Format(CStr(lngHours), "00:") & _
Format(CStr(lngMin), "00:") & Format(CStr(lngSec), "00") & " Play"
End Sub
Public Sub LaengeMP3()
Dim lngSec As Long, lngMin As Long, lngHours As Long
lngLaengeMP3 = Abfrage("status MP3Name length")
lngSec = Fix(lngLaengeMP3 / 1000)
lngHours = (lngSec - (lngSec Mod 60)) / 60 / 60
lngMin = (lngSec - (lngHours * 60) - (lngSec Mod 60)) / 60
lngSec = lngSec - (lngHours * 60 * 60) - (lngMin * 60)
Form1.lblLaenge.Caption = Format(CStr(lngHours), "00:") & _
Format(CStr(lngMin), "00:") & Format(CStr(lngSec), "00") & " Total"
End Sub
Private Function Abfrage(ByVal Abfragetext As String) As Long
Dim strReturn As String
Dim lngResult As Long
strReturn = Space$(256)
lngResult = mciSendString(Abfragetext, strReturn, Len(strReturn), 0&)
Abfrage = Val(strReturn)
End Function Alles funktioniert perfekt wenn meine Form - Form1 heißt.
Ich möchte aber, dass meine Module für alle Form gültig wird (was der Sinn der Sache ist, oder), egal welche Namen sie haben, denn ich brauche noch etwa 30 solchen Forms (Unterschied nur DateienPfad), die selbstverständlich kann ich nicht alle als Form1 definieren. Was muss ich verändern, dass Module die Gültigkeit für alle Forms hat, egal welche Name sie haben.
Ich habe schon mit:
Dim anyForm As Form probiert, abe es funktioniert nicht.
Bitte um Hilfe
LG
Majbog |