ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
Code Snippets VB.Net

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

IncludeHelp VB.Net 13 OCT 2016

ADVERTISEMENT

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

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 Hexadecimal string to decimal integer value we used CInt() Method which will convert given Hexadecimal value to integer.

Here is the syntax

CInt("&H" & "hex_value")

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

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 hexString As String = Nothing

        hexString = TextBox1.Text.Trim

        'convert into decimal
        Dim decValue As Integer = 0

        decValue = CInt("&H" & hexString)

        MsgBox("Integer value is: " & decValue)

    End Sub
End Class

Output

convert hex to integer in vb.net

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.