Avatar billede mskjoldp Novice
04. oktober 2005 - 09:30 Der er 1 kommentar og
1 løsning

reducer udtryk

Hey E

Er der en fornuftig måde at reducere disse udtryk på?
Kodeopsætter er som en normal formular, hvor HTML data fra en <form> sendes til den side der skal opdatere en access database.
Herunder opsættes så udtryk for hvordan HTML data skal behandles inden de smides i databasen.
Men udtrykkende herunder er meget ens og derfor tænkte jeg om der var en funtion ol. hvorved man kan minimere koden...

...bl.a...bl.a....
If request method = POST then ...bl.a....bl.a....


dim varTO, varTOF, varTO_total, varWO1, varWO1F, varWO1_total, varWO2, varWO2F, varWO2_total, varWO3, varWO3F, varWO3_total, varLDT1, varLDT1F, varLDT1_total, varLDT2, varLDT2F, varLDT2_total, varLDT3, varLDT3F, varLDT3_total
dim varWOA, varWOAF, varWOA_total, varWOB, varWOBF, varWOB_total, varWOC, varWOCF, varWOC_total, varLDTA, varLDTAF, varLDTA_total, varLDTB, varLDTBF, varLDTB_total, varLDTC, varLDTCF, varLDTC_total
dim varDEL_WO1, varDEL_LDT1, varDEL_WO2, varDEL_LDT2, varDEL_WO3, varDEL_LDT3, varDEL_WOA, varDEL_LDTA, varDEL_WOB, varDEL_LDTB, varDEL_WOC, varDEL_LDTC

varWO1 = Server.HTMLEncode(Request("Walk_out_1"))
varWO1F = Server.HTMLEncode(Request("Walk_out_1_farve"))
varLDT1 = Server.HTMLEncode(Request("tid_landing_1"))
varLDT1F = Server.HTMLEncode(Request("tid_landing_1_farve"))
varWO2 = Server.HTMLEncode(Request("Walk_out_2"))
varWO2F = Server.HTMLEncode(Request("Walk_out_2_farve"))
varLDT2 = Server.HTMLEncode(Request("tid_landing_2"))
varLDT2F = Server.HTMLEncode(Request("tid_landing_2_farve"))
varWO3 = Server.HTMLEncode(Request("Walk_out_3"))
varWO3F = Server.HTMLEncode(Request("Walk_out_3_farve"))
varLDT3 = Server.HTMLEncode(Request("tid_landing_3"))
varLDT3F = Server.HTMLEncode(Request("tid_landing_3_farve"))
varWOA = Server.HTMLEncode(Request("Walk_out_a"))
varWOAF = Server.HTMLEncode(Request("Walk_out_a_farve"))
varLDTA = Server.HTMLEncode(Request("tid_landing_a"))
varLDTAF = Server.HTMLEncode(Request("tid_landing_a_farve"))
varWOB = Server.HTMLEncode(Request("Walk_out_b"))
varWOBF = Server.HTMLEncode(Request("Walk_out_b_farve"))
varLDTB = Server.HTMLEncode(Request("tid_landing_b"))
varLDTBF = Server.HTMLEncode(Request("tid_landing_b_farve"))
varWOC = Server.HTMLEncode(Request("Walk_out_c"))
varWOCF = Server.HTMLEncode(Request("Walk_out_c_farve"))
varLDTC = Server.HTMLEncode(Request("tid_landing_c"))
varLDTCF = Server.HTMLEncode(Request("tid_landing_c_farve"))
varDEL_WO1 = Server.HTMLEncode(Request("DEL_WO_1"))
varDEL_LDT1 = Server.HTMLEncode(Request("DEL_LDT_1"))
varDEL_WO2 = Server.HTMLEncode(Request("DEL_WO_2"))
varDEL_LDT2 = Server.HTMLEncode(Request("DEL_LDT_2"))
varDEL_WO3 = Server.HTMLEncode(Request("DEL_WO_3"))
varDEL_LDT3 = Server.HTMLEncode(Request("DEL_LDT_3"))
varDEL_WOA = Server.HTMLEncode(Request("DEL_WO_A"))
varDEL_LDTA = Server.HTMLEncode(Request("DEL_LDT_A"))
varDEL_WOB = Server.HTMLEncode(Request("DEL_WO_B"))
varDEL_LDTB = Server.HTMLEncode(Request("DEL_LDT_B"))
varDEL_WOC = Server.HTMLEncode(Request("DEL_WO_C"))
varDEL_LDTC = Server.HTMLEncode(Request("DEL_LDT_C"))

                                                                                                                                                                                   
If varDEL_WO1 = "" Then
    If varWO1F <> "" then
        varWO1_total = Server.HTMLEncode(Request("Walk_out_1")) & " " & Server.HTMLEncode(Request("Walk_out_1_farve"))
    Elseif varWO1 = "" then
        varWO1_total = Server.HTMLEncode(Request("Walk_out_1_farve"))
    Elseif varWO1F = "" Then
        varWO1_total = Server.HTMLEncode(Request("Walk_out_1"))
    Elseif varWO1 = "" AND varWO1F = "" then
        varWO1_total = ""
    End if
Else
    varWO1_total = ""
End if

If varDEL_LDT1 = "" Then
    If varLDT1F <> "" then
        varLDT1_total = Server.HTMLEncode(Request("tid_landing_1")) & " " & Server.HTMLEncode(Request("tid_landing_1_farve"))
    Elseif varLDT1 = "" then
        varLDT1_total = Server.HTMLEncode(Request("tid_landing_1_farve"))
    Elseif varLDT1F = "" Then
        varLDT1_total = Server.HTMLEncode(Request("tid_landing_1"))
    Elseif varLDT1 = "" AND varLDT1F = "" then
        varLDT1_total = ""
    End if
Else
    varLDT1_total = ""
End if

If varDEL_WO2 = "" Then
    If varWO2F <> "" then
        varWO2_total = Server.HTMLEncode(Request("Walk_out_2")) & " " & Server.HTMLEncode(Request("Walk_out_2_farve"))
    Elseif varWO2 = "" then
        varWO2_total = Server.HTMLEncode(Request("Walk_out_2_farve"))
    Elseif varWO2F = "" Then
        varWO2_total = Server.HTMLEncode(Request("Walk_out_2"))
    Elseif varWO2 = "" AND varWO2F = "" then
        varWO2_total = ""
    End if
Else
    varWO2_total = ""
End if

If varDEL_LDT2 = "" Then
    If varLDT2F <> "" then
        varLDT2_total = Server.HTMLEncode(Request("tid_landing_2")) & " " & Server.HTMLEncode(Request("tid_landing_2_farve"))
    Elseif varLDT2 = "" then
        varLDT2_total = Server.HTMLEncode(Request("tid_landing_2_farve"))
    Elseif varLDT2F = "" Then
        varLDT2_total = Server.HTMLEncode(Request("tid_landing_2"))
    Elseif varLDT2 = "" AND varLDT2F = "" then
        varLDT2_total = ""
    End if
Else
    varLDT2_total = ""
End if

If varDEL_WO3 = "" Then
    If varWO3F <> "" then
        varWO3_total = Server.HTMLEncode(Request("Walk_out_3")) & " " & Server.HTMLEncode(Request("Walk_out_3_farve"))
    Elseif varWO3 = "" then
        varWO3_total = Server.HTMLEncode(Request("Walk_out_3_farve"))
    Elseif varWO3F = "" Then
        varWO3_total = Server.HTMLEncode(Request("Walk_out_3"))
    Elseif varWO3 = "" AND varWO3F = "" then
        varWO3_total = ""
    End if
Else
    varWO3_total = ""
End if

If varDEL_LDT3 = "" Then
    If varLDT3F <> "" then
        varLDT3_total = Server.HTMLEncode(Request("tid_landing_3")) & " " & Server.HTMLEncode(Request("tid_landing_3_farve"))
    Elseif varLDT3 = "" then
        varLDT3_total = Server.HTMLEncode(Request("tid_landing_3_farve"))
    Elseif varLDT3F = "" Then
        varLDT3_total = Server.HTMLEncode(Request("tid_landing_3"))
    Elseif varLDT3 = "" AND varLDT3F = "" then
        varLDT3_total = ""
    End if
Else
    varLDT3_total = ""
End if

If varDEL_WO1 = "" Then
    If varWOAF <> "" then
        varWOA_total = Server.HTMLEncode(Request("Walk_out_a")) & " " & Server.HTMLEncode(Request("Walk_out_a_farve"))
    Elseif varWOA = "" then
        varWOA_total = Server.HTMLEncode(Request("Walk_out_a_farve"))
    Elseif varWOAF = "" Then
        varWOA_total = Server.HTMLEncode(Request("Walk_out_a"))
    Elseif varWOA = "" AND varWOAF = "" then
        varWOA_total = ""
    End if
Else
    varWOA_total = ""
End if

If varDEL_LDTA = "" Then
    If varLDTAF <> "" then
        varLDTA_total = Server.HTMLEncode(Request("tid_landing_a")) & " " & Server.HTMLEncode(Request("tid_landing_a_farve"))
    Elseif varLDTA = "" then
        varLDTA_total = Server.HTMLEncode(Request("tid_landing_a_farve"))
    Elseif varLDTAF = "" Then
        varLDTA_total = Server.HTMLEncode(Request("tid_landing_a"))
    Elseif varLDTA = "" AND varLDTAF = "" then
        varLDTA_total = ""
    End if
Else
    varLDTA_total = ""
End if

If varDEL_WOB = "" Then
    If varWOBF <> "" then
        varWOB_total = Server.HTMLEncode(Request("Walk_out_b")) & " " & Server.HTMLEncode(Request("Walk_out_b_farve"))
    Elseif varWOB = "" then
        varWOB_total = Server.HTMLEncode(Request("Walk_out_b_farve"))
    Elseif varWOBF = "" Then
        varWOB_total = Server.HTMLEncode(Request("Walk_out_b"))
    Elseif varWOB = "" AND varWOBF = "" then
        varWOB_total = ""
    End if
Else
    varWOB_total = ""
End if

If varDEL_LDTB = "" Then
    If varLDTBF <> "" then
        varLDTB_total = Server.HTMLEncode(Request("tid_landing_b")) & " " & Server.HTMLEncode(Request("tid_landing_b_farve"))
    Elseif varLDTB = "" then
        varLDTB_total = Server.HTMLEncode(Request("tid_landing_b_farve"))
    Elseif varLDTBF = "" Then
        varLDTB_total = Server.HTMLEncode(Request("tid_landing_b"))
    Elseif varLDTB = "" AND varLDTBF = "" then
        varLDTB_total = ""
    End if
Else
    varLDTB_total = ""
End if

If varDEL_WOC = "" Then
    If varWOCF <> "" then
        varWOC_total = Server.HTMLEncode(Request("Walk_out_c")) & " " & Server.HTMLEncode(Request("Walk_out_c_farve"))
    Elseif varWOC = "" then
        varWOC_total = Server.HTMLEncode(Request("Walk_out_c_farve"))
    Elseif varWOCF = "" Then
        varWOC_total = Server.HTMLEncode(Request("Walk_out_c"))
    Elseif varWOC = "" AND varWOCF = "" then
        varWOC_total = ""
    End if
Else
    varWOC_total = ""
End if

If varDEL_LDTC = "" Then
    If varLDTCF <> "" then
        varLDTC_total = Server.HTMLEncode(Request("tid_landing_c")) & " " & Server.HTMLEncode(Request("tid_landing_c_farve"))
    Elseif varLDTC = "" then
        varLDTC_total = Server.HTMLEncode(Request("tid_landing_c_farve"))
    Elseif varLDTCF = "" Then
        varLDTC_total = Server.HTMLEncode(Request("tid_landing_c"))
    Elseif varLDTC = "" AND varLDTCF = "" then
        varLDTC_total = ""
    End if
Else
    varLDTC_total = ""
End if

..bl.a....bl.a...


/skjold
Avatar billede mskjoldp Novice
23. oktober 2005 - 20:00 #1
updateret points...
Avatar billede mskjoldp Novice
05. november 2005 - 20:55 #2
lukker uden svar...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester