'v4.B*************************************************** ' File: 2-5mal-input.vbs ' Autor: W.Schmelz (verändert: dieseyer@gmx.de) ' http://source-center.de/forum/showthread.php?t=1738 ' ' http://dieseyer.de ' ' zerlegt / extrahiert aus der Eingabe in eine ' InputBox mehrere Eingaben. '******************************************************* Option Explicit ' Siehe http://dieseyer.de/dse-wsh-lernen.html#OptionExpl Dim Txt, Txt1, Txt2, Txt3, Txt4, Txt5 Dim Eingabe, i, Tst Dim Sym : Sym ="#" ' Trennsymbol " # " evtl. anpassen Dim Titel : Titel =" Input - Box mit 2 bis 5 Einträgen " ' Streichen oder Hinzufügen einer Schleife am Ende ändert Höchstzahl der Einträge ! '******************************************************* Txt = Txt & "Bitte mit Abtrennung durch " & Sym & " eintragen" & VbCRLF & VbCRLF Txt = Txt & "und dabei auf die Reihenfolge achten!" & VbCRLF & VbCRLF & VbCRLF Txt = Txt & "1) Die Pers. Nr. z. B. A 7770007700" & VbCRLF & VbCRLF Txt = Txt & "2) Die Telefonvorwahl z. B. 02374" & VbCRLF & VbCRLF Txt = Txt & "3) Die Telefon - Nr. z. B. 77777" & VbCRLF & VbCRLF Txt = Txt & "4) Name : Schulze - Bochum, Karl - Heinz" & VbCRLF & VbCRLF Txt = Txt & "4) und noch : . . . " & VbCRLF & VbCRLF & VbCRLF Txt = Txt & "Pers.Nr. " & Sym & " Vorwahl " & Sym & " Telefon " & Sym & " Name " & Sym & " Sonstiges" Eingabe = " A788 # 0711 # 540367# Dseyer#doof " ' zum Testen Eingabe = InputBox( VbCRLF & Txt & VbCRLF, Titel, Eingabe ) If Eingabe="" then WScript.Quit If not Right( Eingabe, 1 ) = Sym then Eingabe = Eingabe & Sym ' Falls Symbol rechts vergessen! If Left( Eingabe, 1 ) = Sym then Eingabe = Mid( Eingabe, 2 ) ' Falls Symbol links! ' Die Eingabenfolge wird gemäß den " # " in Abschnitte zerlegt ' und die Teile als Variablen " Txti " definiert Txt = "" Tst = Split( Eingabe, Sym ) ' Eingabe aufteilen und in Array Tst() ablegen for i = LBound( Tst ) to UBound( Tst ) ' jeden Teil auswerten If Left( Tst(i), 1 ) = " " Then Tst(i) = Mid( Tst(i), 2 ) If Left( Tst(i), 1 ) = " " Then Tst(i) = Mid( Tst(i), 2 ) If Right( Tst(i), 1 ) = " " Then Tst(i) = Mid( Tst(i), 1, Len( Tst(i) ) -1 ) If Right( Tst(i), 1 ) = " " Then Tst(i) = Mid( Tst(i), 1, Len( Tst(i) ) -1 ) ' MsgBox i & vbTab & "==>" & Tst(i) & "<==" , , "Txt" ' zum Testen if i = 0 Then Txt1 = Tst(i) : Txt = Txt & i & vbTab & Tst(i) & vbCRLF if i = 1 Then Txt2 = Tst(i) : Txt = Txt & i & vbTab & Tst(i) & vbCRLF if i = 2 Then Txt3 = Tst(i) : Txt = Txt & i & vbTab & Tst(i) & vbCRLF if i = 3 Then Txt4 = Tst(i) : Txt = Txt & i & vbTab & Tst(i) & vbCRLF if i = 4 Then Txt5 = Tst(i) : Txt = Txt & i & vbTab & Tst(i) & vbCRLF next ' MsgBox Txt, , "Txt" ' zum Testen Ende ' Sub - Aufruf WScript.Quit '************************************************************** Sub Ende '************************************************************** ' Kontrollmeldung: Txt=VbCRLF&VbCRLF Txt=Txt&"1) Die Pers. Nr. ist "& Txt1 &VbCRLF&VbCRLF Txt=Txt&"2) Die Telefonvorwahl ist "& Txt2 &VbCRLF&VbCRLF Txt=Txt&"3) Die Telefon - Nr. ist "& Txt3 &VbCRLF&VbCRLF Txt=Txt&"4) Name ist "& Txt4 &VbCRLF&VbCRLF Txt=Txt&"5) und noch ist "& Txt5 &VbCRLF&VbCRLF MsgBox Txt,,Titel End Sub ' Ende