# \$var = \$var + 1 problem

## Recommended Posts

noob question for sure.

\$var = 0

\$var = \$var + 1

why is it that its creating 1111111111, instead of 1 2 3 4 5 6 7..... like i want it to?

##### Share on other sites

```\$var = 0
For \$x = 1 To 10
\$var = \$var + 1
MsgBox(0, "", \$var)
Next```

This works for me???

Edited by rogue5099

My projects:

##### Share on other sites

This:

```\$var = 0
\$var = \$var + 1
\$var = \$var + 1 ;; etc```

Will NOT produce "11...etc". (not even if you used quoted value's) ... your probably using '&' instead of '+' in your real code.

Tip:

(apply's to all, just double, or even triple, for beginners ... or noob's if you like.)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...

##### Share on other sites

The addition operation is not treated as string concatenation in the AutoIt language. Try these examples

```\$var = 1
\$var = \$var + 1
MsgBox(64, "Test 1", \$var)

\$var = "String"
\$var = \$var + 1
MsgBox(64, "Test 2", \$var)

\$var = "String"
\$var = \$var + "1"
MsgBox(64, "Test 3", \$var)```

If the addition operation is used with strings, then the statement is evaluated using the numerical representation of the expression contained in the string. To see/understand the numeric representation of several string expressions see the Number() function in the help file.

## Create an account

Register a new account

×

• Wiki

• Back

• Git