How to Decimal Number converts Hexadecimal Number

I have a question.
I want create MIDI file that is binary file with Hexadecimal Number. My soft method has all function with using decimal number property. I need convert Numbers to Hexadecimal Number.
I get to know &h and Hex method. But Hex method is result to return strings. Then I try Val or CDbl method, but this result is decimal number only maybe.
i.e
Dim theNo As Integer
theNo=Val("&h"+ Hex(123)) // this result is 291 as decimal

How to change decimal number converts Hexadecimal Number?
Do I need original method create?

An integer is just a number; whether it’s shown in hex or in decimal shouldn’t matter, the value of the integer will be the same.

Thank you replay. I realize that. Integer property is able to have hexadecimal. But I want converting. I use set &h number to integer. Just I want 100 to Convert to &h64 or so.

Numbers are stored as … well numbers…

100 is a number… &h64 is a representation of that number… but it still has a value of 100

you can create a STRING (ie. representation) as s="&h"+hex(100) as you previously noted.

your MIDI file is just a stream of BYTES each one containing a value between 0 and 255

So it really does not matter what “base” you do you calculations in…

if you need to create a stream of values… use CHRB(100) [watch for encoding issues]

Thank you replay. Oh I test it.

Dave sann, thank you! I made it.

theB.WriteByte 100

I tested. In result I see 64 on binary editor! That is very easy. Thank you very much

If you want to pass a hexadecimal number to a signed value type directly in the IDE, you need to use Ctype() to do it.

Hex() and it’s similar variants are for turning text strings representing a number, i.e. “#FFFFFF” into an actual value type.

so :

```dim Some_Number as integer Some_Number = Ctype(&hFFFFFFFF, Integer)```

But you should understand the difference between signed, unsigned etc number

luke thank you!

I will try this.

This is to share some information to everyone here Hexa decimal number system has values from 0-9 and A-F where A=10, B=11, C=12, D=13, E=14 and F=15.

Hope this one helps you. This information I read it from this link.