online 1
gast (50)

/ Forum / Tabellenkalkulation

TabellenkalkulationTabellenkalkulation

Fragevon MarcoDelMestre vom 26.02.2020, 09:48 Options

Rückgabewert MsgBox

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



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


Antwort schreiben

Antwort 1 von Flupo vom 26.02.2020, 10:11 Options

So funktioniert die MSG-Box:

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 vom 26.02.2020, 10:13 Options

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 Function

Zum Testen:

Sub Testaufruf()
If TestMacro = vbYes Then
    MsgBox "JA gewählt."
Else
    MsgBox "NEIN gewählt."
End If
End Sub

Arno

Ähnliche Themen

MsgBox beim starten der Accessdatei
Robsenponte  19.01.2007 - 60 Hits - 2 Antworten

msgbox button
nighty  03.03.2007 - 102 Hits - 1 Antwort

VBScript File "codes,befehle...?"
bääääärli  31.08.2007 - 185 Hits - 1 Antwort

Datum/Zeit in MsgBox ausgeben lassen
stefanH.  22.02.2008 - 63 Hits - 1 Antwort

Programm ausführen in php
helfer_001  16.06.2008 - 58 Hits - 2 Antworten

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Thu Jan 8 21:07:44 2026