ByVal var As String

S

Shapper

Hello,

What is the difference between using in a function:

Sub Change_Culture(ByVal newCulture As String)

Or

Sub Change_Culture(newCulture As String)

The difference is the ByVal.

Thanks,
Miguel
 
K

Karl Seguin

There is none. parameters are passed by value by default. In previous
version of VB the default was ByRef.

Actually, there is 1 difference: readability. Those unfamiliar with VB.Net
might not know what the default bahaviour is, hence you should always put
it.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
G

Guest

Nothing - except clarity.

ByVal is the default in .NET. To be as clear as possible, you should
specify ByVal (especially when working with developers coming recently from
classic VB where the default was ByRef).

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter
 
S

Steve C. Orr [MVP, MCSD]

They are functionally identical since parameters are ByVal by default.
 
S

Shapper

Thanks,

I wasn't sure but the truth is that the effect was the same using ByVal
or Not.

Thanks once again,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top