How to convert number to string Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

How to convert number to string

Post by MonuKashyap » 20 Jan 2022, 22:43

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

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: How to convert number to string  Topic is solved

Post by boiler » 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

MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

Re: How to convert number to string

Post by MonuKashyap » 20 Jan 2022, 23:15

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,.

MonuKashyap
Posts: 112
Joined: 06 Jun 2016, 21:32

Re: How to convert number to string

Post by MonuKashyap » 21 Jan 2022, 08:04

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,,

User avatar
Chunjee
Posts: 1402
Joined: 18 Apr 2014, 19:05
Contact:

Re: How to convert number to string

Post by Chunjee » 21 Jan 2022, 20:34

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"

Post Reply

Return to “Ask for Help (v1)”