Gruppe
Extern
Problem
Je nach aufrufender UserForm-Schaltfläche sollen aus Textdateien Fragen in ein Label-Feld eingelesen werden.
ClassModule: frmQuestions
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOne_Click()
Call GetText(1)
End Sub
Private Sub cmdTwo_Click()
Call GetText(2)
End Sub
Private Sub cmdThree_Click()
Call GetText(3)
End Sub
Private Sub GetText(iQuestion As Integer)
Dim sFile As String, sTxt As String, sQuestion As String
sFile = ThisWorkbook.Path & "\Frage" & iQuestion & ".txt"
If Dir(sFile) = "" Then
Beep
MsgBox "Die Textdatei " & sFile & " existiert nicht!"
Exit Sub
End If
Close
Open sFile For Input As #1
Do Until EOF(1)
Line Input #1, sTxt
sQuestion = sTxt & vbLf
Loop
Close
lblQuestion.Caption = sQuestion
End Sub
StandardModule: Modul1
Sub DialogAufruf()
frmQuestions.Show
End Sub