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.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application. After that, do the form just like shown below. reverse101

Step 2

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.
  1.    Dim r As Integer
  2.     Public Function Reverse(rn As Integer)
  3.         Dim numbers = Val(TextBox1.Text)
  4.         Dim result As Integer
  5.         While numbers > 0
  6.             rn = numbers Mod 10
  7.             result = result * 10 + rn
  8.             numbers = numbers \ 10
  9.         End While
  10.         Reverse = result
  11.     End Function

Step 3

Do the following codes to display the reverse numbers in another textbox when clicked.
  1.  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2.         TextBox2.Text = Reverse(r)
  3.     End Sub
For any questions about this article. You can contact me @ Email – [email protected] Mobile No. – 09305235027 – TNT FB Account – https://www.facebook.com/onnaj.soicalap

Add new comment