

It supports almost all native PureBasic gadgets, menu and even status bar.

Purebasic select case code#
Imagine if you want to write a code that can test conditions based on the values from two different cells.The PureBasic IDE has a very powerful integrated form designer, which allows to design easily windows and arrange gadgets on them. What I’m trying to say is you can write a code to test multiple conditions with the select case. You can also create a nested condition statement. All 5 cases use a range of numbers and return the value defined in the statement. In the above function, it has five cases to check for the score of the students from a cell. In the below code, the line starts with the case and then condition to test and then a colon, and then the statement to run in that case is true.įunction udfGrade(student_marks As Integer) While writing code for the SELECT CASE, you can use colon operators to write the entire case in one line.

And the second case in the statement checks if the value from the cell A1 is lower than 45 and returns a message box with a message “Fail”.The first case in this statement checks if the value from the cell A1 is greater than or equal to 45 or not and returns a message box with the message “Pass”.You can use comparison operators (=, >,, >=, ,It can test multiple conditions and execute a line of code based on the result.Related: VBA MESSAGE BOX Important Points FIFTH, you have the END SELECT keyword to end the SELECT CASE statement.FOURTH, you have the keyword CASE ELSE and a line of code to show a message box with a message “Can’t Say” if none of the cases are true.THIRD, you again have the keyword case and the condition (“No”) to check from the cell A1 and code to show a message box with the message “It’s a No” if the condition mentioned in case two is true.SECOND, you have the keyword CASE and the condition (“YES”) to check from the cell A1 and code to show a message box with the message “It’s a Yes” if the condition mentioned in case1 is true.FIRST, you have the SELECT CASE keyword and the cell A1 to use as an expression for testing the condition.To understand its syntax, we need to split it into four parts:

In SELECT CASE syntax starts with the keyword “Select” and ends with “End Select”. The syntax for select caseīelow is the syntax that you need to follow to write a select case statement. In this way, you can specify multiple conditions and multiple statements. In this statement, you can specify one condition and then specify a code to execute if that condition is true and then specify a second condition and a code to run if that condition is true. VBA SELECT CASE is a statement to test multiple conditions. It is easier to modify it when you need to adjust one or more of the values in the code.The code you write with SELECT CASE is way more structured than standard conditional code.With SELECT CASE, you can test multiple conditions, especially when you are working more than two.
