Hallo ihr alle,
Ich habe den folgenden Code aber der gibt einen Fehler aus und zwar "Fehler beim Kompilieren Erwartet Datenfeld".Kann jemand mir helfen,den Fehler zu beseitigen.Ich weiss nicht,warum der Fehler auftaucht.
Ich habe den folgenden Code aber der gibt einen Fehler aus und zwar "Fehler beim Kompilieren Erwartet Datenfeld".Kann jemand mir helfen,den Fehler zu beseitigen.Ich weiss nicht,warum der Fehler auftaucht.
Code:
Public Function checkarray(targets() As String, replaces() As String)
Dim i As Integer
Dim size As Integer
Dim results(UBound(targets))
size = UBound(targets)
If (UBound(targets) <> UBound(replaces)) Then
MsgBox "Arrays not equal in size"
Exit Function
End If
For i = 0 To size
results(i) = CheckSpacesInModules(targets(i), replaces(i))
Next i
checkarray = results
End Function
Public Function CheckSpacesInModules(target As String, replace As String)
On Error GoTo Err_CheckSpacesInModules
Dim lngCounterA As Long, lngCounterB As Long
Dim modModule As Module
Dim zahl
For lngCounterA = 0 To Modules.count - 1
Set modModule = Modules.Item(lngCounterA)
zahl = 0
With modModule
For lngCounterB = 1 To .CountOfLines
If InStr(Trim(.Lines(lngCounterB, 1)), target) > 0 Then
Dim tempStr As String
tempStr = replace(.Lines(lngCounterB, 1), target, replace)
.ReplaceLine lngCounterB, tempStr
zahl = zahl + 1
End If
Next lngCounterB
End With
CheckSpacesInModules = zahl
MsgBox "New York kam im Modul " & modModule & " " & zahl & " mal vor."
Next lngCounterA
Exit_CheckSpacesInModules:
Exit Function
Err_CheckSpacesInModules:
MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
Resume Exit_CheckSpacesInModules
End Function