Power By I-WEB S.r.l.
DATABASE

  Lezioni

  Access e Internet

ASP

  Introduzione

  Lezioni

  Build Asp page

 
MANUALI SCARICABILI

  Manuale Access

  Manuale Asp

 
COMUNITA'/CHAT

  Comunità virtuale

  Chat


 

PAGINE ASP
Periodico n. 2- Febbraio 1999

Indice

Cicli condizionali
Function e sub-function - manipolazione di date
Variabili del server
Ms Acess Database


Clicca qui per scaricare
il cap. stampabile

Function e sub-function - manipolazione di date

Innanzi tutto chiariamo in quale contesto è meglio usare un Function piuttosto che una Sub-Function.

La Sub è utile quando abbiamo del codice che non deve restituire alcun valore.

La Function invece è da considerare quando si presenta la necessità di restituire qualche valore.

- Sub -

<CODE>
Sub NameOfSubRoutine(parameter1, parameter2)
    'some code...
End Sub
</CODE>

- Function -

<CODE>
Function CheckForSpaces(x)
    If InStr(x," ") > 0 Then
        CheckForSpaces = true
    Else
        CheckForSpaces = false
    End If
End Function
</CODE>

By: Jared Stauffer

PASSAGGIO DI VARIABILI CON UNA FUNCTION O SUB-FUNCTION

NameOfFunction(parameter1, parameter2)

o più direttamente...

CheckForChar(eaddress, "@")

Per utilizzare il valore restituito da una Function il metodo più pratico è quello di usare una sintassi del tipo:
variabilefinale = ChackForChar(eaddress, "@")

Manipolazione di date

- Isolamento di un particolare -

Vediamo con un esempio questo discorso, in quanto la manipolazione delle date risulta indispensabile ai fini di analisi e impostazione filtri.

<CODE>
var1 = Now()
Response.Write("var1 = " & var1 & "<br>")
Response.Write("var1 part yyyy = " & DatePart("yyyy", var1) & "<br>")
Response.Write("var1 part m = " & DatePart("m", var1) & "<br>")
Response.Write("var1 part q = " & DatePart("q", var1) & "<br>")
Response.Write("var1 part y = " & DatePart("y", var1) & "<br>")
Response.Write("var1 part d = " & DatePart("d", var1) & "<br>")
Response.Write("var1 part w = " & DatePart("w", var1) & "<br>")
Response.Write("var1 part ww = " & DatePart("ww", var1) & "<br>")
Response.Write("var1 part h = " & DatePart("h", var1) & "<br>")
Response.Write("var1 part n = " & DatePart("n", var1) & "<br>")
Response.Write("var1 part s = " & DatePart("s", var1) & "<br>")
</CODE>

Risultato:
var1 = 9/1/99 1:18:15 PM
var1 part yyyy = 1999
var1 part m = 9
var1 part q = 3
var1 part y = 244
var1 part d = 1
var1 part w = 4
var1 part ww = 36
var1 part h = 13
var1 part n = 18
var1 part s = 15

- Day, Mounth, Year... -

<CODE>
var1 = "04/04/1999"<br>
Response.Write("var1 = " & var1 & "<br>")
Response.Write("For var1 the day is " & Day(var1) & "<br>")
Response.Write("For var1 the month is " & Month(var1) & "<br>")
Response.Write("For var1 the year is " & Year(var1) & "<br>")
Response.Write("For var1 the weekday is " & WeekDay(var1, 1) & "<br>")
Response.Write("For var1 the weekdayname is " & WeekDayName(WeekDay(var1), false, 1) & "<br>")
</CODE>

Results:
var1 = 04/04/1999
For var1 the day is 4
For var1 the month is 4
For var1 the year is 1999
For var1 the weekday is 1
For var1 the weekdayname is Sunday

- Operazioni di aggiunta/ sottrazione -

<CODE>
var1 = Now()
Response.Write("var1 = " & var1 & "<br>")
Response.Write("var1 plus 10 days = " & DateAdd("d", 10, var1) & "<br>")
Response.Write("var1 minus 10 days = " & DateAdd("d", -10, var1) & "<br>")
Response.Write("var1 plus 3 months = " & DateAdd("m", 3, var1) & "<br>")
Response.Write("var1 minus 3 months = " & DateAdd("m", -3, var1) & "<br>")
Response.Write("var1 plus 2 hours = " & DateAdd("h", 2, var1) & "<br>")
Response.Write("var1 minus 2 hours = " & DateAdd("h", -2, var1) & "<br>")
</CODE>

Results:
var1 = 9/1/99 1:41:04 PM
var1 plus 10 days = 9/11/99 1:41:04 PM
var1 minus 10 days = 8/22/99 1:41:04 PM
var1 plus 3 months = 12/1/99 1:41:04 PM
var1 minus 3 months = 6/1/99 1:41:04 PM
var1 plus 2 hours = 9/1/99 3:41:04 PM
var1 minus 2 hours = 9/1/99 11:41:04 AM

- Between per trovare intervalli di date -

<CODE>
var1 = "04/04/1999"<br> var2 = "01/11/2000"<br>

Response.Write("var1 = " & var1 & "<br>")
Response.Write("var2 = " & var2 & "<br>")
Response.Write("var1 to var2 is " & DateDiff("d", var1, var2) & " days <br>")
Response.Write("var1 to var2 is " & DateDiff("m", var1, var2) & " months <br>")
Response.Write("var1 to var2 is " & DateDiff("yyyy", var1, var2) & " year(s) <br>")
</CODE>

Results:
var1 = 04/04/1999
var2 = 01/11/2000
var1 to var2 is 282 days
var1 to var2 is 9 months
var1 to var2 is 1 year(s)

By: Jared Stauffer

Prosegui...

Indice

Cicli condizionali
Function e sub-function - manipolazione di date
Variabili del server
Ms Acess Database

 

 

   ARTICOLI & VIAGGI
  Articoli

  Viaggi & Foto
 
   DICONO DI NOI
  Ecco quello che dicono di noi...
 
   SONDAGGIO
  Vota subito!
 
   ISCRIVITI GRATIS ALLA NEWSLETTER
Iscriviti ora!

© 2002

 by I-Web S.r.l. All rights reserved.

Website Design by I-Web S.rl.