Can VBScript pass parameters by reference? _vbs

Source: Internet
Author: User
Can VBScript pass parameters by reference?

For example

function DDD (str)
Str=str & "12345"
End Function

Abc= "54321"

Want to turn ABC into "5432112345" by DDD (ABC)

How to change it?
Answer:
<script language=vbs> function ddd (str) STR=STR & "12345" End Function abc= "54321" DDD ABC msgbox ABC &L T;/script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

There's no place to change.

In fact, the default method of passing parameters in VBScript is ByRef, if you want to pass the value, write
Function DDD (ByVal str)
...

However, when calling a function defined by the VBS in JS, the parameter is passed by value, indicating that byref is not used
If you want to change the value, you can wrap it up with an object, such as
<script language=vbs> Sub Chgarg (a) a.x=100 a.y=100 End Sub </script> <script LANGUAGE=JSCRIPT&G T var t={x:0,y:0,show:function () {alert ("this.x=" +this.x+ ", this.y=" +this.y)} t.show (); Chgarg (t); T.show (); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.