0

Hi everyone , i am trying to fully uderstand the recursion method in vb but i still have problems in making the programs work, Can anyone help me to create a program that convert decimal numbers to binary numbers or point me to the right direction,I know that this can be done by continuing dividing by 2 until the is no more result left but in a recursive method i have problems. Thank you

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by nse2008
0

Hi i found this code on the web that works but can someone tell my how does this works


Private Function RecursionFunc(ByRef AsciiNum As Short, ByRef SubNum As Short) As Object

If AsciiNum - SubNum > 0 Then
txtNew.Text = txtNew.Text & 1 'Add a 1 to indicate that it contains a subnum in it
If SubNum <> 1 Then 'Check to make sure it's not 1
RecursionFunc(AsciiNum - SubNum, SubNum / 2) 'Call myself with the new asciinum and subnum
End If
Else
txtNew.Text = txtNew.Text & 0 'Add a zero to indicate that the subnum is not contained
If SubNum <> 1 Then 'Check to make sure it's not 1
'Call myself with the same asciinum because it does not contain a subnum and make subnum the next smallest
RecursionFunc(AsciiNum, SubNum / 2)
End If
End If

0

Hi i found this code on the web that works but can someone tell my how does this works

u said it works but you want to someone tell u how it works?confusing statement.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.