Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:55 18 Sep 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : VAL in Micromite

Author Message
helltek
Newbie

Joined: 04/02/2015
Location: United States
Posts: 29
Posted: 05:26am 15 Nov 2015
Copy link to clipboard 
Print this post

How does the "VAL" statement work in Micromite Basic?
I get ZERO value.


Text$="Test"
for i = 1 to LEN(Text$)
DA$ = MID$(Text$,i,1)
DT1 = VAL(DA$)
Print "Text$="Text$" DA$="DA$" DT1="DT1
next i


>
> run
Text$=Test DA$=T DT1= 0
Text$=Test DA$=e DT1= 0
Text$=Test DA$=s DT1= 0
Text$=Test DA$=t DT1= 0
>

 
Chris Roper
Senior Member

Joined: 19/05/2015
Location: South Africa
Posts: 280
Posted: 05:32am 15 Nov 2015
Copy link to clipboard 
Print this post

Val converts a string into its equivalent numeric value.
Letters of the Alphabet are not Numeric so return 0.

Change your test string to Text$="1234"
and run it again you will see what I mean.

Cheers
Chris

http://caroper.blogspot.com/
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1629
Posted: 05:34am 15 Nov 2015
Copy link to clipboard 
Print this post

  helltek said   How does the "VAL" statement work in Micromite Basic?
I get ZERO value


Just try

Print val("5")

or
a$="123"
Print val(a$)


Michael


causality ≠ correlation ≠ coincidence
 
sc05027
Newbie

Joined: 01/01/2015
Location: Hong Kong
Posts: 10
Posted: 05:38am 15 Nov 2015
Copy link to clipboard 
Print this post

or use ASC(arg) to returns the ASCII code for the first letter in the argument

SC
 
helltek
Newbie

Joined: 04/02/2015
Location: United States
Posts: 29
Posted: 05:39am 15 Nov 2015
Copy link to clipboard 
Print this post

Thanks for quick reply.
Is there a way to get the ascii value of a text character?
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1629
Posted: 05:39am 15 Nov 2015
Copy link to clipboard 
Print this post

Maybe you are looking for ASC?
The Ascii value of a character?


causality ≠ correlation ≠ coincidence
 
helltek
Newbie

Joined: 04/02/2015
Location: United States
Posts: 29
Posted: 05:46am 15 Nov 2015
Copy link to clipboard 
Print this post

Thanks. Yes, that's what I need. The ascii value of text character. The "VAL" statement confused me thinking it would give me the ascii value.

 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1629
Posted: 05:51am 15 Nov 2015
Copy link to clipboard 
Print this post

that happens sometimes ...
causality ≠ correlation ≠ coincidence
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9643
Posted: 03:01pm 15 Nov 2015
Copy link to clipboard 
Print this post

I used VAL all the time by mistake when I needed ASC, if that makes you feel any better. It would seem to be a common mistake when learning.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025