Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    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. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

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

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

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

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

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    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
  •