Is it a letter or number

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kaspian
Posts: 1
Joined: 25 Oct 2020, 10:57

Is it a letter or number

25 Oct 2020, 11:05

Hallo,

can you please help me figure this out..

Code: Select all

string := "A7106952"
x := substr(string,1,1)
If (x is integer)
MsgBox %x% is a number!

Thanks you for answers.
Last edited by gregster on 09 Nov 2020, 19:19, edited 3 times in total.
Reason: Spam link removed.
User avatar
mikeyww
Posts: 27123
Joined: 09 Sep 2014, 18:38

Re: Is it a letter or number

25 Oct 2020, 11:23

Code: Select all

string := "A7106952"
x := substr(string,1,1)
If x is integer
 MsgBox %x% is a number!
Else MsgBox, Not!
See documentation for the syntax.
User avatar
Chunjee
Posts: 1439
Joined: 18 Apr 2014, 19:05
Contact:

Re: Is it a letter or number

25 Oct 2020, 14:09

yes has to follow if Var is Type or if Var is not Type

(x is integer) will have unexpected results.


https://github.com/Shambles-Dev/AutoHotkey-Type_Checking/blob/master/IsType.ahk is a decent library that makes this more approachable.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, mikeyww, peter_ahk and 138 guests