Page 1 of 1

How to convert number to string

Posted: 20 Jan 2022, 22:43
by MonuKashyap
for ex
num:=123
;here this is a number format
and how do i get this in string format

To understand better,
here is the main problem
[Not working]
wb.document.GetElementbyId(Data).value:=123

[Working]
wb.document.GetElementbyId(Data).value:="123"

My problem is :
wb.document.GetElementbyId(Data).value:= "%num%"
is not working!

TIA

Re: How to convert number to string  Topic is solved

Posted: 20 Jan 2022, 23:03
by boiler
No matter what the contents of your variable, this is incorrect syntax:

Code: Select all

wb.document.GetElementbyId(Data).value := "%num%"

Generally, it would be:

Code: Select all

wb.document.GetElementbyId(Data).value := num

I'm not sure why the above wouldn't work as is, but if you really need the contents to be seen as a string, try concatenating it with a null string like this:

Code: Select all

wb.document.GetElementbyId(Data).value := "" num

You might also try:

Code: Select all

wb.document.GetElementbyId(Data).innerText := num

Re: How to convert number to string

Posted: 20 Jan 2022, 23:15
by MonuKashyap
boiler wrote:
20 Jan 2022, 23:03
No matter what the contents of your variable, this is incorrect syntax:

Code: Select all

wb.document.GetElementbyId(Data).value := "%num%"

Generally, it would be:

Code: Select all

wb.document.GetElementbyId(Data).value := num

I'm not sure why the above wouldn't work as is, but if you really need the contents to be seen as a string, try concatenating it with a null string like this:

Code: Select all

wb.document.GetElementbyId(Data).value := "" num

You might also try:

Code: Select all

wb.document.GetElementbyId(Data).innerText := num
okay, ill try and inform,.

Re: How to convert number to string

Posted: 21 Jan 2022, 08:04
by MonuKashyap
boiler wrote:
20 Jan 2022, 23:03
No matter what the contents of your variable, this is incorrect syntax:

Code: Select all

wb.document.GetElementbyId(Data).value := "%num%"

Generally, it would be:

Code: Select all

wb.document.GetElementbyId(Data).value := num

I'm not sure why the above wouldn't work as is, but if you really need the contents to be seen as a string, try concatenating it with a null string like this:

Code: Select all

wb.document.GetElementbyId(Data).value := "" num

You might also try:

Code: Select all

wb.document.GetElementbyId(Data).innerText := num

superb, that line worked
wb.document.GetElementbyId(Data).value := "" num

Thanks friend,,

Re: How to convert number to string

Posted: 21 Jan 2022, 20:34
by Chunjee
One alternative: https://biga-ahk.github.io/biga.ahk/#/?id=tostring

Code: Select all

A := new biga() ; requires https://www.npmjs.com/package/biga.ahk

msgbox, % A.toString(-300)
; => "-300"