Convert Number to Octal in VB.NET

In this article, we will create a program that can convert a given number into octal. Octal describes a base-8 number system. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add only one Button named Button1 and labeled it as "Convert". Insert two textboxes named TextBox1 for inputting a desired number andTextBox2for displaying the output in the octal form. You must design your interface like this: design 3. Put this code in your Button1_Click. This will trigger to convert the inputted number in textbox1 and display the output in octal in textbox2.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim octal As String = Oct(TextBox1.Text)
  3. TextBox2.Text = octal
  4. End Sub
We have first initialized variable octal as a string that will hold the octal equivalent of a number inputted in textbox1 as we have the Oct statement. Oct statement returns a string that will represent the octal value of a number inputted in textbox1. Then the octal value now will be displayed in textbox2.

Output

output Download the source code below and try it! :) For more inquiries just contact my number or e-mail below. Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Add new comment