21. marts 2004 - 12:54
Der er
11 kommentarer og 1 løsning
forsættelse til finde dato ud fra dagsnummer
her er min kode: Når variablen tekst indeholder 3 ord virker det fint, men når den kun indeholder 2 ord melder den fejl ved "whataction(2)"... ..hvad kan jeg gøre??? <% tekst = "sprut 54 lør" %> <% WhatAction = split(tekst," ", -1, 1) %> <% response.write tekst %> <% if whataction(2) <> "" then if whataction(2) <> "" and whataction(2) = "fre" then dato = DateAdd("d",VBfriday-WeekDay(date),date) else end if if whataction(2) <> "" and whataction(2) = "lør" then dato = DateAdd("d",VBSaturday-WeekDay(date),date) end if else tidspunkt = formatdatetime(now(),4) if tidspunkt > "03:01" then dato = date() end if if tidspunkt < "03:00" then dato = date() - 1 end if end if response.write dato %>
Annonceindlæg fra Deloitte
21. marts 2004 - 13:02
#1
Du kan bruge ubound(whataction) det giver det sidste index i arrayet if whataction(ubound(whataction)) <> "" then
21. marts 2004 - 13:04
#2
Hvis arrayet whataction skal indeholde 3 ting så kan du gøre i stil: if ubound(whataction) <> 2 then Response.Write "Fejl i strengen den indeholder ikke 3 ting" else .. resten af koden end if
21. marts 2004 - 13:07
#3
nu ser den sådan ud. den melder inegn fejl nu, men den udskriver heller ikke datoen når der kun er to ord i variablen....?? <% tekst = "sprut 54" %> <% WhatAction = split(tekst," ", -1, 1) %> <% response.write tekst %> <% 'if whataction(2) <> "" then if whataction(ubound(whataction)) <> "" then if whataction(ubound(whataction)) <> "" and whataction(ubound(whataction)) = "fre" then dato = DateAdd("d",VBfriday-WeekDay(date),date) else end if if whataction(ubound(whataction)) <> "" and whataction(ubound(whataction)) = "lør" then dato = DateAdd("d",VBSaturday-WeekDay(date),date) end if else tidspunkt = formatdatetime(now(),4) if tidspunkt > "03:01" then dato = date() end if if tidspunkt < "03:00" then dato = date() - 1 end if end if response.write dato %>
21. marts 2004 - 13:10
#4
variablen tekst indeholder altid enten 2 eller 3 ord...
21. marts 2004 - 13:12
#5
den kommer ind i den del hvor der ikke er noget imellem else og end if if whataction(ubound(whataction)) <> "" then if whataction(ubound(whataction)) <> "" and whataction(ubound(whataction)) = "fre" then dato = DateAdd("d",VBfriday-WeekDay(date),date) else 'HER kommer den ind med 2 ord i end if
21. marts 2004 - 13:15
#6
med mindre der står "fre" eller "lør" som sidste ord, så kommer den ind i en af de if sætnigner. Men den kommer ikke ind i else delen af denne: if whataction(ubound(whataction)) <> "" then Så hvis der er 2 ord skal den så komme ind i else delen??
21. marts 2004 - 13:16
#7
for så skal du prøve at rette dennne: if whataction(ubound(whataction)) <> "" then til: if ubound(whataction) = 2 then
21. marts 2004 - 13:16
#8
nu er den sådan her, men den udskiver ikke dato variablen...?? <% tekst = "sprut 54" %> <% WhatAction = split(tekst," ", -1, 1) %> <% response.write tekst %> <% 'if whataction(2) <> "" then if whataction(ubound(whataction)) <> "" then if whataction(ubound(whataction)) <> "" and whataction(ubound(whataction)) <> "" = "fre" then dato = DateAdd("d",VBfriday-WeekDay(date),date) end if if whataction(ubound(whataction)) <> "" and whataction(ubound(whataction)) <> "" = "lør" then dato = DateAdd("d",VBSaturday-WeekDay(date),date) end if else tidspunkt = formatdatetime(now(),4) if tidspunkt > "03:01" then dato = date() end if if tidspunkt < "03:00" then dato = date() - 1 end if end if response.write dato %>
21. marts 2004 - 13:17
#9
der er altid enten 2 eller 3 ord. I de tilfælde hvor der er 3 ord er det tredje ord altid "fre" eller "lør"
21. marts 2004 - 13:18
#10
ok, så prøv at rette: if whataction(ubound(whataction)) <> "" then Til: if ubound(whataction) = 2 then
21. marts 2004 - 13:20
#11
yes nu virker det vist. tak eagleeye. læg et svar...
21. marts 2004 - 13:21
#12
ok :) et svar.
Kurser inden for grundlæggende programmering