Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Resumir codigo

Estas en el tema de Resumir codigo en el foro de Visual Basic clásico en Foros del Web. Como puedo resumir este codigo ya sea con una funcion u otra Código: If Abs(rs!intervencion1) > 0 Then rs2.Open "SELECT contratos.id_contratos, contratos.intervencion1, nomenclador.codigo, nomenclador.descripcion, nomenclador.complejidad, ...
  #1 (permalink)  
Antiguo 24/10/2011, 22:57
 
Fecha de Ingreso: septiembre-2009
Mensajes: 108
Antigüedad: 14 años, 8 meses
Puntos: 1
Resumir codigo

Como puedo resumir este codigo ya sea con una funcion u otra

Código:
If Abs(rs!intervencion1) > 0 Then
                rs2.Open "SELECT contratos.id_contratos, contratos.intervencion1, nomenclador.codigo, nomenclador.descripcion, nomenclador.complejidad, nomenclador.pagina " & _
                "FROM contratos INNER JOIN nomenclador ON contratos.intervencion1 = nomenclador.id_nomenclador " & _
                "WHERE contratos.id_contratos = " & rs!id_contratos & " ", cnn, adOpenDynamic, adLockPessimistic
                oItem.SubItems(11) = rs2!descripcion
                rs2.Close
            End If
            oItem.SubItems(12) = IIf(Abs(rs!bilateral1) = 1, gstrX, vbNullString)
            oItem.SubItems(13) = IIf(Abs(rs!multiple1) = 1, gstrX, vbNullString)
                If rs!via1 = vbNullString Then
                    oItem.SubItems(14) = vbNullString
                    oItem.SubItems(15) = vbNullString
                ElseIf rs!via1 = "M" Then
                    oItem.SubItems(14) = gstrX
                    oItem.SubItems(15) = vbNullString
                ElseIf rs!via1 = "D" Then
                    oItem.SubItems(14) = vbNullString
                    oItem.SubItems(15) = gstrX
                End If
                
            If Abs(rs!intervencion2) > 0 Then
                rs2.Open "SELECT contratos.id_contratos, contratos.intervencion2, nomenclador.codigo, nomenclador.descripcion, nomenclador.complejidad, nomenclador.pagina " & _
                "FROM contratos INNER JOIN nomenclador ON contratos.intervencion2 = nomenclador.id_nomenclador " & _
                "WHERE contratos.id_contratos = " & rs!id_contratos & " ", cnn, adOpenDynamic, adLockPessimistic
                oItem.SubItems(16) = rs2!descripcion
                rs2.Close
            End If
            oItem.SubItems(17) = IIf(Abs(rs!bilateral2) = 1, gstrX, vbNullString)
            oItem.SubItems(18) = IIf(Abs(rs!multiple2) = 1, gstrX, vbNullString)
                If rs!via2 = vbNullString Then
                    oItem.SubItems(19) = vbNullString
                    oItem.SubItems(20) = vbNullString
                ElseIf rs!via2 = "M" Then
                    oItem.SubItems(19) = gstrX
                    oItem.SubItems(20) = vbNullString
                ElseIf rs!via2 = "D" Then
                    oItem.SubItems(19) = vbNullString
                    oItem.SubItems(20) = gstrX
                End If
            If Abs(rs!intervencion3) > 0 Then
                rs2.Open "SELECT contratos.id_contratos, contratos.intervencion3, nomenclador.codigo, nomenclador.descripcion, nomenclador.complejidad, nomenclador.pagina " & _
                "FROM contratos INNER JOIN nomenclador ON contratos.intervencion3 = nomenclador.id_nomenclador " & _
                "WHERE contratos.id_contratos = " & rs!id_contratos & " ", cnn, adOpenDynamic, adLockPessimistic
                oItem.SubItems(21) = rs2!descripcion
                rs2.Close
            End If
            oItem.SubItems(22) = IIf(Abs(rs!bilateral3) = 1, gstrX, vbNullString)
            oItem.SubItems(23) = IIf(Abs(rs!multiple3) = 1, gstrX, vbNullString)
                If rs!via3 = vbNullString Then
                    oItem.SubItems(24) = vbNullString
                    oItem.SubItems(25) = vbNullString
                ElseIf rs!via3 = "M" Then
                    oItem.SubItems(24) = "gstrX"
                    oItem.SubItems(25) = vbNullString
                ElseIf rs!via3 = "D" Then
                    oItem.SubItems(24) = vbNullString
                    oItem.SubItems(25) = gstrX
                End If
            If Abs(rs!intervencion4) > 0 Then
                rs2.Open "SELECT contratos.id_contratos, contratos.intervencion4, nomenclador.codigo, nomenclador.descripcion, nomenclador.complejidad, nomenclador.pagina " & _
                "FROM contratos INNER JOIN nomenclador ON contratos.intervencion4 = nomenclador.id_nomenclador " & _
                "WHERE contratos.id_contratos = " & rs!id_contratos & " ", cnn, adOpenDynamic, adLockPessimistic
                oItem.SubItems(26) = rs2!descripcion
                rs2.Close
            End If
            oItem.SubItems(27) = IIf(Abs(rs!bilateral4) = 1, gstrX, vbNullString)
            oItem.SubItems(28) = IIf(Abs(rs!multiple4) = 1, gstrX, vbNullString)
                If rs!via4 = vbNullString Then
                    oItem.SubItems(29) = vbNullString
                    oItem.SubItems(30) = vbNullString
                ElseIf rs!via4 = "M" Then
                    oItem.SubItems(29) = gstrX
                    oItem.SubItems(30) = vbNullString
                ElseIf rs!via4 = "D" Then
                    oItem.SubItems(29) = vbNullString
                    oItem.SubItems(30) = gstrX
                End If
            If Abs(rs!intervencion5) > 0 Then
                rs2.Open "SELECT contratos.id_contratos, contratos.intervencion5, nomenclador.codigo, nomenclador.descripcion, nomenclador.complejidad, nomenclador.pagina " & _
                "FROM contratos INNER JOIN nomenclador ON contratos.intervencion5 = nomenclador.id_nomenclador " & _
                "WHERE contratos.id_contratos = " & rs!id_contratos & " ", cnn, adOpenDynamic, adLockPessimistic
                oItem.SubItems(31) = rs2!descripcion
                rs2.Close
            End If
            oItem.SubItems(32) = IIf(Abs(rs!bilateral5) = 1, gstrX, vbNullString)
            oItem.SubItems(33) = IIf(Abs(rs!multiple5) = 1, gstrX, vbNullString)
                If rs!via5 = vbNullString Then
                    oItem.SubItems(34) = vbNullString
                    oItem.SubItems(35) = vbNullString
                ElseIf rs!via5 = "M" Then
                    oItem.SubItems(34) = gstrX
                    oItem.SubItems(35) = vbNullString
                ElseIf rs!via5 = "D" Then
                    oItem.SubItems(34) = vbNullString
                    oItem.SubItems(35) = gstrX
                End If

Etiquetas: vb
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:25.