Subroutine not returning any values

  • Thread starter Thread starter Kjell Weding
  • Start date Start date
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
 
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.
 
Back
Top