Probleme mit VB

ricciardo

Cadet 1st Year
Registriert
Mai 2007
Beiträge
11
Ich programmier noch nicht lange, aber ich will was machen was ich nicht hinbekomme...!

Ich will ein "If then" Befehl machen. Ne Inputbox erscheint und da steht "Hallo, wie geht's?". Wenn der Benutzer jetzt "Gut" eingibt soll eine Msgbox erscheinen, auf der steht: "COOL!"

Danke

Riccardo
 
versuchs mal so:

Code:
If InputBox("Hallo, wie geht's?", "Hallo") = "Gut" Then MsgBox "COOL!", vbInformation


oder in mehreren Zeilen mit Variable:
Code:
eingabe = InputBox("Hallo, wie geht's?", "Hallo")

If eingabe = "Gut" Then
    MsgBox "COOL!", vbInformation
End If


mit else:
Code:
eingabe = InputBox("Hallo, wie geht's?", "Hallo")

If eingabe = "Gut" Then
    MsgBox "COOL!", vbInformation
Else
    MsgBox "Nicht gut? Schade.", vbInformation
End If



mfg
luky37
 
Ich würde das so lösen:

Code:
eingabe = InputBox("Hallo, wie geht's?", "Hallo")
 
If ucase(eingabe) = ucase("Gut") Then
    MsgBox "COOL!", vbInformation
Else
    MsgBox "Nicht gut? Schade.", vbInformation
End If

durch die Verwendung von UCase() ist sichergestellt, dass auch die Eingaben gut/gUt etc richtig erkannt werden. (Natürlich nur, wenn das ganze nicht case-sensitiv sein soll)
 
Zuletzt bearbeitet: (Tippfehler behoben)
Danke!

Funzt alles und geht super...!
 
Zurück
Oben