# Thread: case is... (2000 sr 1)

1. ## case is... (2000 sr 1)

... is possible to simplify this many IF statement with a CASE IS command?

If Sess0.Screen.GETSTRING(23, 2, 3) = "125" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "SPORTELLO NON ATTIVO"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "128" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "SPORTELLO STAGIONALE CHIUSO"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "122" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "CODICE CAB NON TROVATO"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "112" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "CODICE AIB NON TROVATO"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "141" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "BANCA NON TROVATA IN LOCALITA'"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "129" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "PARAMETRI STAGIONALITA' ERRATI"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "115" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "BANCA NON ATTIVA"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "143" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "INCONGRUENZA IN LOCALITA'"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "144" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "BANCA NON ATTIVA IN LOCALITA'"
End If

If Sess0.Screen.GETSTRING(23, 2, 3) = "115" Then
Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))
Range("I" + RIGA2) = "BANCA NON ATTIVA"
End If

2. ## Re: case is... (2000 sr 1)

Yes, like this:

Range("H" + RIGA2) = Trim(Sess0.Screen.GETSTRING(23, 2, 3))

Select Case Sess0.Screen.GETSTRING(23, 2, 3)
Case "125"
Range("I" + RIGA2) = "SPORTELLO NON ATTIVO"
Case "128"
Range("I" + RIGA2) = "SPORTELLO STAGIONALE CHIUSO"
Case "122"
Range("I" + RIGA2) = "CODICE CAB NON TROVATO"
...
...
End Select

3. ## Re: case is... (2000 sr 1)

Thank you Hans
Reading your posts almost invariably expands my limited knowledge.

4. ## Re: case is... (2000 sr 1)

Hans, sorry me, but have a difficult to insert you suggestion...
... Patience for me;-)

5. ## Re: case is... (2000 sr 1)

If you compare your original question to my reply, you will see that each

If Sess0.Screen.GETSTRING(23, 2, 3) = "..." Then
...
Range("I" + RIGA2) = "..."
End If

part corresponds to

Case "..."
Range("I" + RIGA2) = "..."

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•