Search from Cycling Blog

Converting decimal number into Octal number[VB.NET]

Converting decimal number into Octal number

Language: VB.NET

Author: Aamir Mustafa

E-Mail: aamir_mustafa2007@msn.com

aamirmustafa134@gmail.com

Introduction:


This article will show you how to convert a decimal number into octal number.

How to Use:

Create an empty project

On the form, add a button, two textboxes

  1. btnOctal
  2. txtNum
  3. txtOctal

We will take input through txtNum and show binary number into txtBinary and we will use btnOctal for converting decimal into Octal.

Write following code in btnOctal Click event.

Code:

End Sub Private Sub btnOctal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOctal.Click

Try

Dim num As Long 'number that we will take through input

num = CLng(txtNum.Text) 'assigning textbox value to num and converting string value to long using CLng function

If IsNumeric(num) Then 'checking that text box contains numeric value

txtOctal.Text = Convert.ToString(num, 8) 'here 8 means converting to octal

End If

Catch ex As Exception

MessageBox.Show("Plz enter the number", "Octal", MessageBoxButtons.OK, MessageBoxIcon.Information)

txtNum.Focus()

End Try

End Sub

 

0 comments: