ADVERTISEMENT
ADVERTISEMENT
Code Snippets VB.Net

VB.Net - Convert Integer (Decimal) to Hexadecimal String.

IncludeHelp VB.Net 13 OCT 2016

ADVERTISEMENT

In this VB.Net code we will learn how to convert a decimal integer value to its equivalent hexadecimal string?

In this example we created a sample form with two components textbox and button, conversion operation will be performed on button click event and value will be entered in textbox.

To convert decimal integer value to Hexadecimal string we used Hex() Method which will convert given Integer Value to Hexadecimal String.

Here is the syntax

Hex(integer_value)

VB.Net Code - Convert Decimal (Integer) to Hexadecimal String

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'get the value from text box - value should be in hex string

        Dim decValue As Integer = 0
        Dim hexString As String = Nothing

        decValue = Int(TextBox1.Text.Trim)


        'convert into hexadecimal 
        hexString = Hex(decValue)

        MsgBox("Hexadecimal value is: " & hexString)

    End Sub
End Class

Output

convert integer to hex in vb.net

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.