<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>elseif Archive - Robert Skibbe</title>
	<atom:link href="https://robbelroot.de/blog/tag/elseif/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>alias RobbelRoot – Freelance Full Stack Developer .NET</description>
	<lastBuildDate>Fri, 16 Jul 2021 07:54:53 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://robbelroot.de/wp-content/uploads/2020/12/cropped-favicon-32x32.png</url>
	<title>elseif Archive - Robert Skibbe</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>VBScript If Else</title>
		<link>https://robbelroot.de/blog/vbscript-if-else/</link>
					<comments>https://robbelroot.de/blog/vbscript-if-else/#respond</comments>
		
		<dc:creator><![CDATA[Robert Skibbe]]></dc:creator>
		<pubDate>Thu, 15 Jul 2021 17:26:53 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Visual Basic Script]]></category>
		<category><![CDATA[Visual Basic Script lernen]]></category>
		<category><![CDATA[andernfalls]]></category>
		<category><![CDATA[basic]]></category>
		<category><![CDATA[branch]]></category>
		<category><![CDATA[branching]]></category>
		<category><![CDATA[dann]]></category>
		<category><![CDATA[else]]></category>
		<category><![CDATA[elseif]]></category>
		<category><![CDATA[falls]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[selektion]]></category>
		<category><![CDATA[then]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[verzweigung]]></category>
		<category><![CDATA[verzweigungen]]></category>
		<category><![CDATA[visual]]></category>
		<category><![CDATA[visual basic script]]></category>
		<category><![CDATA[wenn]]></category>
		<guid isPermaLink="false">https://robbelroot.de/?p=4216</guid>

					<description><![CDATA[<p>VBScript If Else Du möchtest mit VBScript If Else &#8211;Anweisungen Entscheidungen, bzw. Verzweigungen in deinem Code realisieren? Kein Problem, lerne in diesem Beitrag wie Du das &#8222;If Then Else&#8222;-Konstrukt richtig anwendest. Vielleicht interessieren Dich auch andere Beiträge zu einem späteren Zeitpunkt: VBScript Array, MsgBox, InStr. Hintergrund – VBScript If Else &#8230;</p>
<p>Der Beitrag <a href="https://robbelroot.de/blog/vbscript-if-else/">VBScript If Else</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><a href="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else.png"><img fetchpriority="high" decoding="async" width="1024" height="536" src="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-1024x536.png" alt="" class="wp-image-4219" srcset="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-1024x536.png 1024w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-300x157.png 300w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-768x402.png 768w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-700x366.png 700w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-332x174.png 332w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else.png 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></a><figcaption>VBScript If Else</figcaption></figure>






<h2 class="wp-block-heading">VBScript If Else</h2>



<p>Du <strong>möchtest </strong>mit <strong>VBScript If Else</strong> &#8211;<strong>Anweisungen Entscheidungen</strong>, bzw. <strong>Verzweigungen </strong>in deinem Code <strong>realisieren</strong>?</p>



<p>Kein Problem, <strong>lerne </strong>in diesem Beitrag <strong>wie </strong>Du das &#8222;<strong>If Then Else</strong>&#8222;-Konstrukt richtig <strong>anwendest</strong>.</p>



<p><strong>Vielleicht </strong>interessieren Dich auch <strong>andere Beiträge </strong>zu einem späteren Zeitpunkt: <strong><a href="/blog/vbscript-array" target="_blank" rel="noreferrer noopener">VBScript Array</a></strong>, <strong><a href="/blog/vbscript-msgbox" target="_blank" rel="noreferrer noopener">MsgBox</a></strong>, <strong><a href="/blog/vbscript-instr" target="_blank" rel="noreferrer noopener">InStr</a></strong>.</p>



<h2 class="wp-block-heading">Hintergrund – VBScript If Else</h2>



<p><strong>Entscheidungen </strong>– ein grundlegender Baustein allen <strong>Lebens</strong>, mal <strong>Gute</strong>, mal <strong>Schlechte</strong>, manchmal <strong>instinktiv </strong>und manchmal <strong>rational</strong>.</p>



<p>Sie <strong>bestimmen </strong>unseren <strong>Alltag </strong>als Menschen, als Individuen und <strong>ziehen Folgeentscheidungen nach </strong>sich.</p>



<p>So ist es <strong>auch in </strong>der Welt der <strong>Programmierung</strong>, denn auch dort <strong>müssen </strong>ständig <strong>Entscheidungen getroffen </strong>werden.</p>



<h2 class="wp-block-heading">Verzweigungen </h2>



<p><strong>Entscheidungen </strong>werden in der Programmierung häufig <strong>als Verzweigungen</strong>, oder auch als <strong>Selektion </strong>bezeichnet.</p>



<p>Denn <strong>anhand gewisser </strong>von uns festgelegter <strong>Kriterien</strong>, kann der Programm-Code sich in <strong>verschiedene Wege unterteilen </strong>und Folge-Code ausgeführt werden.</p>



<p>Die <strong>If-Else Verzweigung</strong> <strong>unterscheidet </strong>sich z. B. <strong>von </strong>der bekannten <strong>Mehrfachselektion </strong>&#8222;Select Case&#8220; (in anderen Sprachen auch Switch genannt).</p>



<h3 class="wp-block-heading">Simple Verzweigung – VBScript If Else</h3>



<p><strong>Bei </strong>einer eher <strong>simpleren Verzweigung </strong>haben wir <strong>einen</strong>, <strong>oder mehrere </strong>Ausgangspunkte <strong>verschiedener Abfragemöglichkeiten</strong>.</p>



<p>Ich <strong>kann </strong>zum Beispiel <strong>abfragen</strong>, <strong>ob </strong>gerade die <strong>Sonne scheint</strong>, <strong>ob </strong>dabei <strong>Wolken vorbeiziehen </strong>und <strong>ob </strong>es <strong>regnet</strong>.</p>



<p><strong>Eventuell </strong>kann ich <strong>auf </strong>eine <strong>Kombination </strong>dieser Fälle auch noch <strong>anders reagieren</strong>, <strong>wenn </strong>ein <strong>weiterer Punkt </strong>wie eine <strong>Bewässerungsautomatik </strong>hinzukommt.</p>



<p>Wie <strong>wir sehen</strong>, sind das alles <strong>eventuell </strong>völlig voneinander <strong>unabhängige </strong>Beispiele, Welche wir <strong>kombinieren </strong>und <strong>abfragen </strong>können.</p>



<h3 class="wp-block-heading">Mehrfachselektion</h3>



<p><strong>Bei </strong>der <strong>Mehrfachselektion </strong>sieht es anders aus, dort ist <strong>eigentlich immer </strong>die <strong>Rede von </strong>einem <strong>einzelnen Ausgangspunkt</strong>.</p>



<p>Das <strong>heißt</strong>, wir <strong>überprüfen </strong>einen <strong>Wert </strong>und <strong>schauen welcher </strong>einzelne <strong>Fall </strong>dazu <strong>passt</strong>, mit dem wir dann <strong>passend reagieren</strong>.</p>



<p><strong>Einige Sprachen bieten </strong>hierbei auch die <strong>Möglichkeit </strong>gewisse &#8222;<strong>Ranges</strong>&#8220; <strong>abzuarbeiten</strong>, <strong>statt </strong>nur <strong>einzelne Werte </strong>zu erlauben.</p>



<p>So <strong>könnte man </strong>ein <strong>Symbol </strong>anhand der <strong>Lautstärke </strong>des PCs so gestalten, dass es <strong>sich der Lautstärke</strong> in <strong>gewissen Bereichen anpasst</strong>, oder wenn es die <strong>Bereiche überschreitet</strong>.</p>



<p>Die <strong>Mehrfachselektion </strong>werden wir zu einem <strong>späteren Zeitpunkt</strong>, also vermutlich in einem <strong>separaten Beitrag bearbeiten</strong>.</p>



<h2 class="wp-block-heading">Eine Abfrage – VBScript If Else</h2>



<p><strong>An dieser Stelle </strong>nutze ich die Gelegenheit, dir ein <strong>kurzes </strong>und simples <strong>Beispiel </strong>einer <strong>VBScript If Else</strong> Abfrage zu <strong>zeigen</strong>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim firstName
firstName = "Robert"

If firstName = "John" Then
    MsgBox("Oh, your name is John?")
End If

If firstName = "Robert" Then
    MsgBox("Oh, maybe you are RobbelRoot?")
End If</pre>



<p><strong>Hier legen </strong>wir eine <strong>Variable </strong>namens &#8222;firstName&#8220; <strong>fest</strong>, Welche wir <strong>anschließend mit </strong>dem <strong>Wert </strong>&#8222;Robert&#8220; <strong>versehen</strong>.</p>



<p><strong>Dann starten </strong>wir eine erste <strong>Abfrage</strong>, in der wir <strong>prüfen</strong>, <strong>ob </strong>der <strong>Name </strong>&#8222;<strong>John</strong>&#8220; in der Variable steht.</p>



<p><strong>Da John nicht </strong>in der Variable <strong>steht</strong>, <strong>wird </strong>die erste MsgBox <strong>nicht ausgegeben</strong>.</p>



<p>Die <strong>zweite Abfrage wird </strong>eine MsgBox <strong>ausgeben</strong>, <strong>da </strong>der gesuchte <strong>Name </strong>&#8222;Robert&#8220; in der Variable <strong>steht</strong>.</p>



<p>Du <strong>kannst </strong>den <strong>Namen </strong>testweise gerne einmal <strong>auf </strong>z. B. &#8222;<strong>Bob</strong>&#8220; ändern, <strong>dann </strong>würde <strong>nichts ausgegeben </strong>werden.</p>



<p><strong>Oder verwende </strong>stattdessen doch einmal &#8222;<strong>John</strong>&#8222;, um die <strong>erste Meldung </strong>zu <strong>sehen</strong>.</p>



<h2 class="wp-block-heading">Der Else-Part – VBScript If Else</h2>



<p><strong>Kommen </strong>wir nun zum <strong>Teil</strong>, <strong>wo </strong>wir das erste Mal das &#8222;<strong>Else</strong>&#8222;-Schlüsselwort <strong>verwenden</strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim age
age = 16
If age >= 18 Then
    MsgBox("Ok, old enough!")
Else
    MsgBox("Sorry, you're too young :(!")
End If</pre>



<p>Du siehst hier eine <strong>kleine Altersprüfung</strong>, wo wir eine <strong>Variable namens </strong>&#8222;<strong>age</strong>&#8220; deklarieren.</p>



<p><strong>Danach weisen </strong>wir dem &#8222;age&#8220; die <strong>Zahl 16 zu</strong> und <strong>führen </strong>anschließend eine kleine <strong>Überprüfung </strong>durch.</p>



<p><strong>Wenn </strong>das <strong>Alter größer gleich 18</strong>, die Person also volljährig ist, <strong>geben </strong>wir eine kleine <strong>Erfolgsmeldung aus</strong>.</p>



<p>In <strong>jedem anderen Fall </strong>allerdings, bekommt die Person eine <strong>Meldung</strong>, <strong>dass </strong>Sie noch <strong>zu jung </strong>ist.</p>



<h3 class="wp-block-heading">Visuelle Darstellung</h3>



<p>Hier siehst Du die <strong>visuelle Darstellung </strong>analog zu einem <strong>Programmablaufplan</strong>:</p>



<figure class="wp-block-image size-large"><a href="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung.png"><img decoding="async" width="569" height="400" src="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung.png" alt="VBScript If Else Beispiel Altersprüfung" class="wp-image-4233" title="VBScript If Else Beispiel Altersprüfung" srcset="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung.png 569w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-300x211.png 300w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-332x233.png 332w" sizes="(max-width: 569px) 100vw, 569px" /></a><figcaption>VBScript If Else Beispiel Altersprüfung</figcaption></figure>



<p>Dort <strong>sehen wir </strong>den einen <strong>Ausgangspunkt</strong>, wo sich entschieden wird, <strong>ob </strong>die <strong>Person </strong>nun <strong>volljährig </strong>ist (Weg nach <strong>unten</strong>), oder nicht (Weg nach <strong>rechts</strong>).</p>



<h2 class="wp-block-heading">Andernfalls wenn? ElseIf</h2>



<p>Nun kommen wir zu dem <strong>letzten kleinen Part</strong>, wo ich mir ein <strong>Szenario </strong>überlegt habe, dass die Person <strong>einen </strong>&#8222;<strong>Muttizettel</strong>&#8220; hat.</p>



<p><strong>Dadurch </strong>würde Sie also eine <strong>explizite Erlaubnis </strong>ihrer Eltern bekommen <strong>und </strong>mit dem <strong>Alter 16 und 17 </strong>trotzdem <strong>hineinkommen</strong>.</p>



<p><strong>Mit ElseIf </strong>kann man <strong>beliebig </strong>viele weitere <strong>Abfragen </strong>in die Verzweigung <strong>einbauen</strong>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="visualbasic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Dim age
age = 16
Dim hasMumPaper
hasMumPaper = True
If age >= 18 Then
    MsgBox("Ok, old enough!")
ElseIf age >= 16 And age &lt;= 17 And hasMumPaper Then
    MsgBox("Ok, you're too young, but your mum allowed, nice :)!")
Else
    MsgBox("Sorry, you're too young :(!")
End If</pre>



<h3 class="wp-block-heading">Visuelle Darstellung</h3>



<p>Das <strong>Beispiel mit </strong>dem <strong>Muttizettel </strong>siehst Du <strong>hier </strong>als <strong>visuelle </strong>Darstellung:</p>



<figure class="wp-block-image size-large"><a href="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-mit-Muttizettel.png"><img decoding="async" width="904" height="629" src="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-mit-Muttizettel.png" alt="VBScript If Else Beispiel Altersprüfung mit Muttizettel" class="wp-image-4238" title="VBScript If Else Beispiel Altersprüfung mit Muttizettel" srcset="https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-mit-Muttizettel.png 904w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-mit-Muttizettel-300x209.png 300w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-mit-Muttizettel-768x534.png 768w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-mit-Muttizettel-700x487.png 700w, https://robbelroot.de/wp-content/uploads/2021/07/VBScript-If-Else-Beispiel-Alterspruefung-mit-Muttizettel-332x231.png 332w" sizes="(max-width: 904px) 100vw, 904px" /></a><figcaption>VBScript If Else Beispiel Altersprüfung mit Muttizettel</figcaption></figure>
<p>Der Beitrag <a href="https://robbelroot.de/blog/vbscript-if-else/">VBScript If Else</a> erschien zuerst auf <a href="https://robbelroot.de">Robert Skibbe</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://robbelroot.de/blog/vbscript-if-else/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
