# From TOF : How do I coerce the result of &h into a UInt32 if I already know the value is in the legal range?

**URL:** <https://ifnotnil.com/t/from-tof-how-do-i-coerce-the-result-of-h-into-a-uint32-if-i-already-know-the-value-is-in-the-legal-range/1346>\
**Category:** Other\
**Created:** [20 November 2020 17:57 UTC](https://ifnotnil.com/t/from-tof-how-do-i-coerce-the-result-of-h-into-a-uint32-if-i-already-know-the-value-is-in-the-legal-range/1346 "2020-11-20T17:57:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [20 November 2020 17:57 UTC](https://ifnotnil.com/t/from-tof-how-do-i-coerce-the-result-of-h-into-a-uint32-if-i-already-know-the-value-is-in-the-legal-range/1346/1 "2020-11-20T17:57:50Z")

</div>

Am I confused or isn’t the most simple solution

```auto
Var X As UInt32
Var H as String = "&H123456"
X=Val(h)

```

if “H” isn’t a string then it is already a numeric value, and a simple assignment is all that is required

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [20 November 2020 19:41 UTC](https://ifnotnil.com/t/from-tof-how-do-i-coerce-the-result-of-h-into-a-uint32-if-i-already-know-the-value-is-in-the-legal-range/1346/2 "2020-11-20T19:41:51Z")

</div>

There are several  
Just assign the &h to a Uint32 works too

```auto
Dim i As UInt32 = &h1234

```

Or the use of val as you note
