Supportnet / Forum / Tabellenkalkulation
Rückgabewert MsgBox
Frage
Hallo Leute,
Ich habe wieder mal ein Problemchen.
Wie erhalte ich den Wert der jeweils gedrückten Taste
(Ja oder Nein) aus der MsgBox im TestMacro.
Die Abfrage 'Antwort = MsgBox "....' funzt so nicht.
Vielen Dank im Voraus
mfg
Marco
[code]
Sub AddUDFToCategory()
Application.MacroOptions _
Macro:="TestMacro", _
Description:="This function gives back the 'Hello world' message!", _
Category:=14, _
HelpFile:=ThisWorkbook.Path & "\CHM-example.chm", _
HelpContextID:=0
End Sub
Function TestMacro()
MsgBox "EINGABE WIEDERHOLEN ?", _
Buttons:=vbYesNo + vbExclamation + vbMsgBoxHelpButton + vbDefaultButton2, _
Title:="E I N G A B E - T E S T E R", _
HelpFile:="D:\ZIP\WinHTMLExcel\CHM-example.chm", _
Context:=0
End Function
[/code]
Antwort 1 von Flupo
So funktioniert die MSG-Box:
Damit das Ganze eine Funktion wird, musst du aber noch ein Paar Dinge bei der Deklaration beachten.
Besser also so:
Gruß Flupo
antwort = MsgBox("EINGABE WIEDERHOLEN ?", vbYesNo, _
"E I N G A B E - T E S T E R")
Damit das Ganze eine Funktion wird, musst du aber noch ein Paar Dinge bei der Deklaration beachten.
Besser also so:
Function TestMacro() As Integer
antwort = MsgBox("EINGABE WIEDERHOLEN ?", vbYesNo, _
"E I N G A B E - T E S T E R")
TestMacro = antwort
End Function
Gruß Flupo
Antwort 2 von Arno_Nym
Function TestMacro() As VbMsgBoxResult
TestMacro = MsgBox("EINGABE WIEDERHOLEN ?", _
Buttons:=vbYesNo + vbExclamation + vbMsgBoxHelpButton + vbDefaultButton2, _
Title:="E I N G A B E - T E S T E R", _
HelpFile:="D:\ZIP\WinHTMLExcel\CHM-example.chm", _
Context:=0)
End FunctionZum Testen:
Sub Testaufruf()
If TestMacro = vbYes Then
MsgBox "JA gewählt."
Else
MsgBox "NEIN gewählt."
End If
End SubArno

