top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Recursion functions in VB.Net

+3 votes

Can anyone could show some simple examples of recursion functions in VB.Net?

posted Mar 3, 2014 by Merry

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
Best answer

The following will be an easy example for recursive function in vb .net

Module Module1

        Function Recursive(ByVal value As Integer, ByRef count As Integer) As Integer
        Console.WriteLine("Recursive({0}, {1})", value, count)

        count = count + 1
        If value >= 100 Then
            Return value
        End If
        Return Recursive(value * 2, count)
        End Function

        Sub Main()
        Dim count As Integer = 0
        Dim total As Integer = Recursive(5, count)

        Console.WriteLine("Total = {0}", total)
        Console.WriteLine("Count = {0}", count)
        End Sub

    End Module

the output will be like ::

Recursive(5, 0)
Recursive(10, 1)
Recursive(20, 2)
Recursive(40, 3)
Recursive(80, 4)
Recursive(160, 5)
Total = 160
Count = 6
answer Mar 7, 2014 by Asmita Agrawal
Similar Questions
+4 votes
+2 votes

Is there a class/method we can use in to transform a website in html format to xml format? If there is can you please type the codes out thanks!

+4 votes

How to create Create, read, write and delete event logs in VB.NET

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.