70 likes | 310 Views
VB Conditionals. If Then, Select Case. If Then. Useful computer programs typically have to make a lot of decisions. In VB, If…Then code is used for decision making. The code below demonstrates the most commonly used If…Then patterns in VB.
E N D
VB Conditionals If Then, Select Case
If Then • Useful computer programs typically have to make a lot of decisions. • In VB, If…Then code is used for decision making. • The code below demonstrates the most commonly used If…Then patterns in VB. • The full code for these examples can be found in Conditionals.zip, available in Lecture materials.
If Then…Else If • Generally, I prefer either Select Case or a series of If Thens to using Else If; however • The code below seems to be the best way to determine which radio button is selected:
Select Case • When you want to choose among several options based on the value of an expression, you can use Select Case. • The full code for these examples can be found in Conditionals.zip, available in Lecture materials.
Select Case • Here’s another Select Case example. • Note that it uses the colon (“:”) to combine two lines of code into one. • This example is demonstrated in the video (see slide 29)
Another Select Case Example • This example demonstrates several different Case formats that can be used: