Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2012 returning value from sub or function

$
0
0
I'm returning to Basic after programming in it 25 years ago. Actually could do it then. I am trying to re-establish a program I wrote then and am at wits end, and I didn't have much of that then. Following is my simplistic code example. Have spent at least 8 hours just trying to understand how to replace the old "gosub" command.

Public Class Form1

Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim x As Long

x = 6

findx(x)

Label1.Text = x



End Sub


Function findx(ByVal x As Long) As Long

x = 9
Label2.Text = x
Return x
End Function

End Class


Obviously all I am trying to do I to get the value of "x" from the function back to the subroutine calling it.

If I don't set the value of "x" in the sub it prints "0".

Any help?

Thanks.

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>