String to Single?

How do you convert a string into a single data type? Thanks.

Dim value As Single = Single.FromText("42.23")

Thanks a lot!

@Paul Lefebvre I’m getting an error when I try to use a string value?

Parameter “theText” expects type Text, but this is type String.

My Code in a change event of popupmenu:

sngNozDiam = Single.FromText(me.Text)

“old” framework

sngNozDiam=VAL(me.text)

Thanks!

To go from a String to a Text, use the ToText method:

sngNozDiam = Single.FromText(me.Text.ToText)

[quote=202218:@Paul Lefebvre]To go from a String to a Text, use the ToText method:

sngNozDiam = Single.FromText(me.Text.ToText)

But, why?

Text to string is implicit ; string to text requires ToText.

And the reason for this, if anyone asks, is that converting from a Test to a String is guaranteed to work and be lossless. Going from a String to a Text, on the other hand, can fail due to the String not having an encoding or having an invalid encoding (in which case an exception gets thrown).

My question was: Why convert to text at all in this situation? Just use Val().

I was just noting ToText for completeness in case people are unaware of it. It can be needed when mixing frameworks.