ByVal v ByRef

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,676
Office Version
  1. 365
Platform
  1. Windows
It is my understanding that I should use the ByVal keyword if I am
planning to modify the parameter. Is that correct?

Or is it bad form to modify the function parameters at all?

Example:

Public Sub Write2File(byval FileID As String, Data As String)

FileID = FileID & ".txt"

...
 
Its also been a long time since I did non-VB programming, but I recall (from 6510 A.L.) that in binary all the digits of True are 1, including the negative flag bit, thus True is equivalent to -1.

The VBA equivalence of True and -1, I find normal.
The Excel worksheet equivalence of TRUE and 1 is what I find odd.
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Its also been a long time since I did non-VB programming, but I recall (from 6510 A.L.) that in binary all the digits of True are 1, including the negative flag bit, thus True is equivalent to -1.

The VBA equivalence of True and -1, I find normal.
The Excel worksheet equivalence of TRUE and 1 is what I find odd.
Don't get me wrong, I agree with you fully... -1 makes more sense to me than +1 also (I was just pointing out another example of where VB is contrary to other programming languages), but for some reason, other languages seem to have opted for +1 just like the programmers of Excel did.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top