Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Convert from decimal to hexidecimal?

Convert from decimal to hexidecimal?

Scheduled Pinned Locked Moved Visual Basic
question
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Wike
    wrote on last edited by
    #1

    Is there a simple way to convert a decimal to an hexidecimal?

    D D A 3 Replies Last reply
    0
    • A Adam Wike

      Is there a simple way to convert a decimal to an hexidecimal?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Since everything is represented internally in Binary, the only "hexadecimal conversion" you're going to get would be when it's formatted into a string for display or some other human-readable purpose. That would be String.Format("{0:X}", value).

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      1 Reply Last reply
      0
      • A Adam Wike

        Is there a simple way to convert a decimal to an hexidecimal?

        D Offline
        D Offline
        Dalek Dave
        wrote on last edited by
        #3

        In VB.Net... dim string hex = Convert.ToString(i, 16); Or in VB6... use a textbox and three labels:

        Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 Then
        KeyAscii = 0
        Label1.Caption = Hex$(Text1.Text)
        If Len(Label1.Caption) < 4 Then
        Label2.Caption = "00"
        Label3.Caption = Label1.Caption
        Else
        Label2.Caption = Left$(Label1.Caption, 2)
        Label3.Caption = Right$(Label1.Caption, 2)
        End If
        End If
        End Sub

        Run the program, type any integer legal number value and press ENTER.

        ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave

        modified on Friday, April 30, 2010 10:27 AM

        D 1 Reply Last reply
        0
        • D Dalek Dave

          In VB.Net... dim string hex = Convert.ToString(i, 16); Or in VB6... use a textbox and three labels:

          Private Sub Text1_KeyPress(KeyAscii As Integer)
          If KeyAscii = 13 Then
          KeyAscii = 0
          Label1.Caption = Hex$(Text1.Text)
          If Len(Label1.Caption) < 4 Then
          Label2.Caption = "00"
          Label3.Caption = Label1.Caption
          Else
          Label2.Caption = Left$(Label1.Caption, 2)
          Label3.Caption = Right$(Label1.Caption, 2)
          End If
          End If
          End Sub

          Run the program, type any integer legal number value and press ENTER.

          ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave

          modified on Friday, April 30, 2010 10:27 AM

          D Offline
          D Offline
          DaveAuld
          wrote on last edited by
          #4

          Dalek Dave wrote:

          Label1.Caption

          That looks very vb6 to me...........in fact it all does. Are you crossing to the dark side?

          Dave Don't forget to rate messages!
          Find Me On: Web|Facebook|Twitter|LinkedIn
          Waving? dave.m.auld[at]googlewave.com

          D 1 Reply Last reply
          0
          • D DaveAuld

            Dalek Dave wrote:

            Label1.Caption

            That looks very vb6 to me...........in fact it all does. Are you crossing to the dark side?

            Dave Don't forget to rate messages!
            Find Me On: Web|Facebook|Twitter|LinkedIn
            Waving? dave.m.auld[at]googlewave.com

            D Offline
            D Offline
            Dalek Dave
            wrote on last edited by
            #5

            Shhh!

            ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave

            D 1 Reply Last reply
            0
            • D Dalek Dave

              Shhh!

              ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave

              D Offline
              D Offline
              DaveAuld
              wrote on last edited by
              #6

              :laugh:

              Dave Don't forget to rate messages!
              Find Me On: Web|Facebook|Twitter|LinkedIn
              Waving? dave.m.auld[at]googlewave.com

              1 Reply Last reply
              0
              • A Adam Wike

                Is there a simple way to convert a decimal to an hexidecimal?

                A Offline
                A Offline
                Adam Wike
                wrote on last edited by
                #7

                Thanks for the help guys :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups