473,473 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Optional and have default value

Hi,

How can I set a parameter of a function optinal and have a default value?
In VB I do like this:
Function myFunction (Optional ByVal bExist as Boolean = False)

What's the equivalent in JScript?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
Nov 18 '05 #1
3 1318
javascript doesn't require that all the parameters defined are passed in. It
is not compiled, and the interpreter doesn't care. So if there are 5
parameters defined, the caller can pass in 0, 1, 2, 3, 4 or 5 arguments in.
So in essence, they are all optional as far as the interpreter is concerned.

As far as default values, you would have to check if a particular argument
is null, and if it, manually assign it a value in your function to have the
effect of having a default value.

"ruca" <ru***@iol.pt> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
Hi,

How can I set a parameter of a function optinal and have a default value?
In VB I do like this:
Function myFunction (Optional ByVal bExist as Boolean = False)

What's the equivalent in JScript?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 18 '05 #2
No direct equivalent. Here is a FAQ on args in JScript. It is not exactly
what you are looking for, but you should be able to adopt to your needs.

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=42

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"ruca" <ru***@iol.pt> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
Hi,

How can I set a parameter of a function optinal and have a default value?
In VB I do like this:
Function myFunction (Optional ByVal bExist as Boolean = False)

What's the equivalent in JScript?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 18 '05 #3
By the way, I was talking about client side jscript...

"Marina" <so*****@nospam.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
javascript doesn't require that all the parameters defined are passed in. It is not compiled, and the interpreter doesn't care. So if there are 5
parameters defined, the caller can pass in 0, 1, 2, 3, 4 or 5 arguments in. So in essence, they are all optional as far as the interpreter is concerned.
As far as default values, you would have to check if a particular argument
is null, and if it, manually assign it a value in your function to have the effect of having a default value.

"ruca" <ru***@iol.pt> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
Hi,

How can I set a parameter of a function optinal and have a default value? In VB I do like this:
Function myFunction (Optional ByVal bExist as Boolean = False)

What's the equivalent in JScript?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gerry Abbott | last post by:
Hi All, Im trying to use thie combination but have not had success. Below is the function It tried the following myriskLevel(2,2) myrisklevel(0,0,2) and the ismissing(Three) alwasy...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
2
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
12
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.