top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Recursion functions in VB.Net

+3 votes
824 views

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 VB.net 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

...