Discussion Locked

basic programming

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
what is a switch? and what is one of its functions?

10 replies

by tclere

The Switch statment is from C. The corresponding statement in basic is Select Case.

by anthony.biondo

A switch is a better way of doing an if statement if there are multiple outcomes. for example if the variable = 'blue' then do this if the variable='green' do this... To make the process easier you create a case or switch statement that says, depending on the variable switch to that case. In the example below you can see an example of a select case in VB/ASP.

select case var_nam

case 'red'
'do whatever

case 'green'
'do whatever else

case 'blue'
'do more stuff

end select

The case statement allows you to expand the possible cases easily. Hope this helps.

Anthony Biondo
Senior Web Developer
Keystone Mercy Health Plan

by rsv

HI,
SWITCH in javascript is just a better way of programming instead of if...endif statement.

SWITCH:
Enables the execution of one or more statements when a specified expression's value matches a label.

Syntax
switch (expression) {
caselabel :
write something
case label :
write something
...
default :
write something
}

Hope this is what u r looking for...:)

by james2933

HOW ARE PAGES USED IN ANAMATION?
WHAT IS A PROGRAM SWITCH? AND NAME ONE USE FOR IT... GW BASIC PROGRAM

by laurenm

Another meaning of the word "switch" in programming is a yes/no type of data item. If you want to do a whole bunch of things in a whole bunch of different places in your program, but only if a certain complicated combination of conditions is true, you might set a "switch" to indicate that the condition is true, so that rather than expressing the complicated combination of conditions again every time you need to check for it, you can just check the "switch".

This discussion is closed to new replies.