Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How do functions work in ASP

[b][red]This message was edited by mac_doggie at 2002-10-16 3:56:30[/red][/b][hr]
Hi,

I'm very new with ASP and was wondering how to format a date. In visual basic I use Format(Date,"dd mmmm yyyy") but this doesn't seem to work in ASP with VBscript.

Can anyone help me with this ?

I Already found out that there are some functions that are very helpfull
[code]
day(now)
month(now)
monthname(month(now))
[/code]

But I want to make my own function so that I can replace monthname(month(now)) so that it will display the monthnames in dutch.

I only don't now how to make my own functions. I tried this but it didn't work:
[code]
private function Maandnaam(mnd) As String
if mnd=1 then Maandnaam = "Januari"
if mnd=2 then Maandnaam = "Februari"
if mnd=3 then Maandnaam = "Maart"
if mnd=4 then Maandnaam = "April"
if mnd=5 then Maandnaam = "Mei"
if mnd=6 then Maandnaam = "Juni"
if mnd=7 then Maandnaam = "Juli"
if mnd=8 then Maandnaam = "Augustus"
if mnd=9 then Maandnaam = "September"
if mnd=10 then Maandnaam = "Oktober"
if mnd=11 then Maandnaam = "November"
if mnd=12 then Maandnaam = "December"
End Function
[/code]


;-)
-mac-
mailto:programmersheaven@mac-doggie.nl
the Netherlands...







Comments

  • alexzhenalexzhen Member Posts: 13
    : [b][red]This message was edited by mac_doggie at 2002-10-16 3:56:30[/red][/b][hr]
    : Hi,
    :
    : I'm very new with ASP and was wondering how to format a date. In visual basic I use Format(Date,"dd mmmm yyyy") but this doesn't seem to work in ASP with VBscript.
    :
    : Can anyone help me with this ?
    :
    : I Already found out that there are some functions that are very helpfull
    : [code]
    : day(now)
    : month(now)
    : monthname(month(now))
    : [/code]
    :
    : But I want to make my own function so that I can replace monthname(month(now)) so that it will display the monthnames in dutch.
    :
    : I only don't now how to make my own functions. I tried this but it didn't work:
    : [code]
    : private function Maandnaam(mnd) As String
    : if mnd=1 then Maandnaam = "Januari"
    : if mnd=2 then Maandnaam = "Februari"
    : if mnd=3 then Maandnaam = "Maart"
    : if mnd=4 then Maandnaam = "April"
    : if mnd=5 then Maandnaam = "Mei"
    : if mnd=6 then Maandnaam = "Juni"
    : if mnd=7 then Maandnaam = "Juli"
    : if mnd=8 then Maandnaam = "Augustus"
    : if mnd=9 then Maandnaam = "September"
    : if mnd=10 then Maandnaam = "Oktober"
    : if mnd=11 then Maandnaam = "November"
    : if mnd=12 then Maandnaam = "December"
    : End Function
    : [/code]
    :
    :
    : ;-)
    : -mac-
    : mailto:programmersheaven@mac-doggie.nl
    : the Netherlands...
    :
    :
    :
    hi, asp supported vbscript and jscript. vbscript is exactly like vb, but the data type don't have to declared. remove private, since you want to make Maandnaam global function. use private, public when you define class or object. for example, use above function

    Dim arr
    arr = Array("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December")

    Function Maandnaam(mnd)
    If LBound(arr) <= mnd And mnd <= UBound(arr) Then
    Maandnaam = arr(mnd)
    Else
    Maandnaam = ""
    End If
    End Function

    goto www.microsoft.com/scripting/ to download the reference. that would help you out.
  • Shawn CarterShawn Carter Member Posts: 0

    || http://forcoder.org || free ebooks and video tutorials about // Swift, Visual Basic .NET, C#, Delphi, Objective-C, C, JavaScript, PL/SQL, PHP, Python, Ruby, Go, Java, C++, R, Visual Basic, Scratch, Perl, MATLAB, Assembly Kotlin, ABAP, Prolog, Rust, Clojure, Lua, Julia, Lisp, FoxPro, Bash, Logo, Erlang, VBScript, Fortran, LabVIEW, Scala, SAS, Scheme, ML, Ada, Awk, F#, Apex, Dart, D, Alice, Hack, COBOL, Crystal, Transact-SQL // ______

Sign In or Register to comment.