Subroutine not returning any values

K

Kjell Weding

I have this code in VB.NET (VS 2005):

Module kvitteringFunk
Public Sub skrivKvittering()
Dim KvittPrt As String = ""
Dim iType As Byte = 0
KvittPrtType(iType, KvittPrt)
' iType should now have the value 1 - BUT IS STILL 0!?!?!?!?!?
' KvittPrt should now have the value "Common" - but is still
"".?!?!?!?!
....
End Sub

Public Sub KvittPrtType(ByVal iType As Byte, ByVal KvittPrt As String)
iType = 1
KvittPrt = "Common"
End Sub
End Module

Why is my subroutine KvittPrtType not returning any values?????

Kjell Weding
Norway
 
P

Patrice

You confused ByVal and ByRef keywords.

http://msdn2.microsoft.com/en-us/library/ddck1z30(VS.71).aspx states :
"Passing an argument by value means the procedure cannot modify the contents
of the variable element in the calling code underlying the argument. Passing
by reference allows the procedure to modify the contents in the same way
that the calling code itself can."

You may want to read the language spec at least once.
 

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

Top