title image


Smiley Problem bei UserForm mit Argument
Hallo liebe Fan-Gemeinde



Ich habe ein Problem mit der Parameterübergabe in

eine UserForm in Excel.In einem Makro habe ich

einen Code Integriert um mir in einer UserForm

Informationen über eine Mp3-Datei anzeigen zu lassen.

Wenn ich den CommandButton1 anklicke erhalte ich

die Fehlermeldung (Argument nicht Optional) mit

dem Verweis auf (MP3_ReadID3v2Tag).

Da dieser Code nicht von mir ist und ich noch

wenig Erfahrung habe, bin ich hiermit leider

etwas überfordert.

Ich würde mich sehr freuen, wenn mir jemand

helfen kann.



Meinen Dank schon mal im Vorraus.



Folgenden Code habe ich in ein Modul integriert:



Option Explicit



Public Type ID3v2

sTitle As String

sArtist As String

sAlbum As String

sComment As String

sYear As String

sGenre As String

sComposer As String

sURL As String

sOrgArtist As String

sCopyright As String

sEncodeBy As String

sTrack As String

sMedium As String

sLen As String

End Type

-----------------------------------------------------------------

Public Function MP3_ID3v2Exists(ByVal sFile As String) As Long



Dim sText As String

Dim sBin As String

Dim sID3 As String * 3

Dim i As Integer

Dim z As Integer

Dim b(4) As Byte

Dim F As Integer

Dim nID3v2Size As Long



On Error GoTo ErrHandler

F = FreeFile

Open sFile For Binary As #F

Get #F, 1, sID3

If sID3 "ID3" Then

MP3_ID3v2Exists = 0

Close #F

Exit Function

End If



Get #F, 7, b(4)

Get #F, 8, b(3)

Get #F, 9, b(2)

Get #F, 10, b(1)



sBin = ""

For z = 2 To 4

For i = 0 To 6

sBin = sBin & CStr(Abs(b(z) And (2 ^ i)))

Next i

Next z

nID3v2Size = 0

For i = 7 To 27

nID3v2Size = nID3v2Size + ((2 ^ i) * Val(Mid(sBin, i - 6, 1)))

Next i

nID3v2Size = nID3v2Size + b(1) + 10

MP3_ID3v2Exists = nID3v2Size

Close #F

Exit Function



ErrHandler:

If F > 0 Then Close #F

MP3_ID3v2Exists = 0

End Function



--------------------------------------------------------------------------------------------

Public Function MP3_ReadID3v2Tag(ByVal sFile As String, ByVal nID3v2Size As Long) As ID3v2



Dim nPos As Long

Dim sFrameType As String * 4

Dim sText As String

Dim sBin As String

Dim sID3 As String * 3

Dim i As Integer

Dim z As Integer

Dim b(4) As Byte

Dim F As Integer

Dim nSize As Long



On Error GoTo ErrHandler



F = FreeFile

Open sFile For Binary As #F



nPos = 11



Do While nPos < nID3v2Size

Get #F, nPos, sFrameType

If InStr(sFrameType, Chr$(0)) > 0 Then

' Fertig nichts mehr zum lesen

Close #F

Exit Do

End If



nPos = nPos + 4

Get #F, nPos, b(4) ' FrameTyp Größe

Get #F, nPos + 1, b(3) ' FrameTyp Größe

Get #F, nPos + 2, b(2) ' FrameTyp Größe

Get #F, nPos + 3, b(1) ' FrameTyp Größe

nPos = nPos + 5



sBin = ""

For z = 2 To 4

For i = 0 To 7 Step 1

sBin = sBin & CStr(Abs(b(z) And (2 ^ i)))

Next i

Next z



nSize = 0

For i = 8 To 30

nSize = nSize + ((2 ^ i) * Val(Mid$(sBin, i - 7, 1)))

Next i

nSize = nSize + b(1)



sText = String$(nSize, vbNullChar)

nPos = nPos + 1

Get #F, nPos, sText

sText = TrimNullChar(sText)



With MP3_ReadID3v2Tag

Select Case sFrameType

Case "TMED"

.sMedium = sText

Case "TLEN"

.sLen = sText

Case "TRCK"

.sTrack = sText

Case "TENC"

.sEncodeBy = sText

Case "WXXX"

.sURL = sText

Case "TCOP"

.sCopyright = sText

Case "TOPE"

.sOrgArtist = sText

Case "TCOM"

.sComposer = sText

Case "COMM"

.sComment = sText

Case "TCON"

sText = Replace(sText, "(", "")

sText = Replace(sText, ")", "")

.sGenre = sText

Case "TYER"

.sYear = sText

Case "TALB"

.sAlbum = sText

Case "TPE1"

.sArtist = sText

Case "TIT2"

.sTitle = sText

End Select

nPos = nPos + nSize

End With

Loop



ErrHandler:

Close #F

End Function



-----------------------------------------------------------------

Private Function TrimNullChar(ByVal sString As String) As String



sString = Replace(sString, vbNullChar, "")

TrimNullChar = Trim$(sString)

End Function





Mit hilfe einer Form1 habe ich verschiedene Labels zur Ausgabe

erstellt und diesen Code eingefügt:



Private Sub CommandButton1_Click()

Dim uID3v2 As ID3v2

Dim sFile As String

Dim nSize As Long





sFile = "C:\test.mp3"



nSize = MP3_ID3v2Exists(sFile)

If nSize > 0 Then

uID3v2 = MP3_ReadID3v2Tag(sFile)



Label1.Caption = "Titel: " & uID3v2.sTitle

Label2.Caption = "Interpret: " & uID3v2.sArtist

Label3.Caption = "Album: " & uID3v2.sAlbum

Label4.Caption = "Track: " & uID3v2.sTrack

Label5.Caption = "Länge: " & uID3v2.sLen

Label6.Caption = "Medium: " & uID3v2.sMedium

Label7.Caption = "Kommentar: " & uID3v2.sComment

End If

End Sub

-------------------------------------------------------------------

Private Sub CommandButton2_Click()

Me.Hide

Unload Me

End Sub

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: