欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp(vbscript)中自定義函數(shù)的默認參數(shù)實現(xiàn)代碼

 更新時間:2020年09月15日 00:10:30   作者:xwing  
這篇文章主要介紹了asp(vbscript)中自定義函數(shù)的默認參數(shù)實現(xiàn)代碼,需要的朋友可以參考下

現(xiàn)代語言的函數(shù)中都可以帶有默認參數(shù),在vbscript系統(tǒng)內(nèi)建的函數(shù)可以帶有可選值(如常用的 split()等等),然而我們自己定義的函數(shù)中無法具有此功能.

下面提供一個方法實現(xiàn)可選參數(shù)的功能.

functin foo(dtype, dsize, value)
   dim a, b
   if TypeName(dtype) <> "Error" Then
       a = dtype
   else
       a = "default value"
   end if
   If TypeName(dsize) <> "Error" Then
       b = dsize
   else
       b = -1
   end if
   .
end function

如示例代碼所示, foo函數(shù)中dtype, dsize均為可選函數(shù),調(diào)用時可以傳參數(shù),也可不傳參數(shù).當不傳參數(shù)的時候,逗號占位符不能丟了,即應該使用 foo(,,"myvalue") 的形式.

相關文章

最新評論