How to Reverse Set of Numbers in VB.net
This simple program can be use as one of your activity in programming subject. It’s kind of interesting to know how to reverse set of numbers especially when done in VB.Net. Surely, your student will have fun learning this simple program.
Open Microsoft Visual Studio 2015 and create a new windows form application. After that, do the form just like shown below.
Double click the form to fire the code view. In the code view, declare an integer and create a function to reverse the given number in the textbox.
- Dim r As Integer
- Public Function Reverse(rn As Integer)
- Dim numbers = Val(TextBox1.Text)
- Dim result As Integer
- While numbers > 0
- rn = numbers Mod 10
- result = result * 10 + rn
- numbers = numbers \ 10
- End While
- Reverse = result
- End Function
Do the following codes to display the reverse numbers in another textbox when clicked.
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- TextBox2.Text = Reverse(r)
- End Sub
For any questions about this article. You can contact me @