Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[VBA] Problem mit Rückgabewerte

Empfohlene Antworten

Veröffentlicht

Hallo ich bin dabei mir eine Klasse zu schreiben welche mir bestimmte Informationen aus einer Datei einliest. Nun habe ich eine Funktion read die mit etwas zurückliefern soll. Zusätzlich habe ich mir eine Funktion geschrieben die mir eigentlich einen TextStream zurückgeben soll denn ich dann in der Funktion read verarbeite. Da bekomme ich beim Ausführen aber eine Fehlermeldung: Sub or Function not defined.

Nun bin ich die paar Zeilen Code schon Zeile für Zeile durchgegangen dabei wird mir zweimal meine Funktion getFile() aufgerufen wenn ich die das zweite mal verlasse kommt die oben Beschriebene Fehlermeldung. Wenn ich aber die zurzeit Auskommentierte Zeile nutze dann klappt das alles wunderbar.

Wie bekomme ich es hin das er mit den TextStream über die getFile Funktion liefert?

Ich verwende VBA 6.0.


Public Function read(sFile As String, sSection As String, sKey As String, sValue As String)

    Dim oTestStream As TextStream

    Dim Fsys As New FileSystemObject


    'Set oTestStream = Fsys.OpenTextFile(sFile, ForReading)

    Set oTestStream = getFile(sFile, 1)


    Dim sLine As String


    While oTestStream.AtEndOfStream = False

        sLine = oTestStream.ReadLine

    Wend

    oTestStream.Close


End Function


Public Function getFile(ByVal sFile As String, Optional ByVal nIOMode As Integer = 1) As TextStream


    Dim oFileSystem: Set oFileSystem = New FileSystemObject


    getFile = oFileSystem.OpenTextFile(sFile, ForReading)


End Function

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.