Suppose there are 2 "if" statements.
I'd like to add something else if they are not the case.
Here is what I have but it doesn't work.
Thanks in advance.
Edit:
I am not familiar with iLogic.
The code below is not actual code but logical thinking.
Your help will be much appreciated.
Select Case 1 And 2
Case 1
"if" statement 1
(e.g. if it is an apple, do something)
Case 2
"if" statement 2
(e.g. if it is a pear, do something)
Case Else
Do something else
End Select
Solved! Go to Solution.
Solved by BeKirra. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Michael.Navara. Go to Solution.
If you want to test one variable to multiple values, you can use Select-Case statement
Dim myValue = 1 'Set your current value
Select Case myValue
Case 1
Logger.Debug("Value is ONE")
Case 2
Logger.Debug("Value is TWO")
Case Else
Logger.Debug("Value is something different")
End Select
If you want to test more than one variable, you need to use If-ElseIf-Else statement
Dim myValue1 = 1
Dim myValue2 = 2
If myValue1 = 1 Then
Logger.Debug("myValue1 is ONE, myValue2 is anything")
ElseIf myValue2 = 2 Then
Logger.Debug("myValue1 is NOT ONE, myValue2 is TWO")
Else
Logger.Debug("myValue1 is NOT ONE, myValue2 is NOT TWO")
End If
Or you can use nested If statements
Dim myValue1 = 1
Dim myValue2 = 2
If myValue1 = 1 Then
If myValue2 = 1 Then
Logger.Debug("myValue1 is ONE, myValue2 is ONE")
ElseIf myValue2 = 2 Then
Logger.Debug("myValue1 is ONE, myValue2 is TWO")
Else
Logger.Debug("myValue1 is ONE, myValue2 is NOT ONE or TWO")
End If
ElseIf myValue1 = 2 Then
If myValue2 = 1 Then
Logger.Debug("myValue1 is TWO, myValue2 is ONE")
ElseIf myValue2 = 2 Then
Logger.Debug("myValue1 is TWO, myValue2 is TWO")
Else
Logger.Debug("myValue1 is TWO, myValue2 is NOT ONE or TWO")
End If
Else
Logger.Debug("myValue1 is NOT ONE or TWO, myValue2 is anything")
End If
It depends on what do you want to test.
Thanks.
Here is what I wrote after reading your code.
Will it work?
Dim Letter As String
Dim Person As String
Dim Greeting As String
Dim Meeting As String
Select Case Letter
Case 1
If Person = "A"
Greeting = "Hello"
End If
Case 2
If Person = "B"
Greeting = "Hi"
End If
Case Else
Meeting = "Good Morning"
End Select
Syntax of your code is almost correct, but I don't understand what do you try to do.
Can you describe your use case? What is your inputs, conditions and expected result?
Note: You can't compare value of variable Letter (String) with expected value 1, 2 (Integer)
@BeKirra, see if these example help clarify things.
Dim Letter As String Dim Greeting As String Dim LetterList = New String(){"A", "B", "Z"} Letter = InputListBox("Prompt", LetterList, "A" , Title := "Letter List", ListName := "List") Select Case Letter Case "A" Greeting = "Hello" Case "B" Greeting = "Hi" Case Else Greeting = "Good Morning" End Select MsgBox(Greeting,,"iLogic")
Same but using an If statement rather than a Select Case statement.
Dim Letter As String Dim Greeting As String Dim LetterList = New String() {"A", "B", "Z" } Letter = InputListBox("Prompt", LetterList, "A", Title := "Letter List", ListName := "List") If Letter = "A" Then Greeting = "Hello" ElseIf Letter = "B" Then Greeting = "Hi" Else Greeting = "Good Morning" End If MsgBox(Greeting, , "iLogic")
iLogic is based on Visual Basic.
Here is VB "Select Case" Syntax:
Thanks to ALL.
I have figured out the logical statements based on what you suggested as my case is more complicate.
Can't find what you're looking for? Ask the community or share your knowledge.