VS 2013 Substract from textbox (hexadecimal)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: VS 2013 Substract from textbox (hexadecimal)

  1. #1
    Join Date
    Jan 2015
    Posts
    1

    VS 2013 Substract from textbox (hexadecimal)

    Hello. Here is my code.
    It reading bytes from *.bin file and show it in textbox1

    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
           Dim OFD As New OpenFileDialog
            Dim fullFile() As Byte
     
            If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
                fullFile = File.ReadAllBytes(OFD.FileName)
                TextBox1.AppendText(fullFile(&H2E).ToString("X2") & " ")
                TextBox1.AppendText(fullFile(&H2F).ToString("X2"))
            End If
     
        End Sub
    Now I want to add substraction in textbox2.
    example:
    H2E - BC
    H2F - CD

    BCCD - 2222 = 9AABB

    Textbox2. = result

    I tired with this, but it gives result in decimal

    Code:
       TextBox2.Text = Val(TextBox1.Text) - Val("2222")

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,875

    Re: VS 2013 Substract from textbox (hexadecimal)

    You need to make it hex
    Code:
    TextBox2.Text = Hex (Val(TextBox1.Text) - Val("2222"))
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center