我有以下脚本,但是没有错误执行它。我想在URL中放置一个变量和ping。
#include <Excel.au3>
$sFilePath1 = "D:Desktop1.xlsx"
$oExcel = _ExcelBookOpen($sFilePath1, 0)
For $i = 1 To 2 ; Loop
Local $username = _ExcelReadcell($oExcel, $i, 1) ;Reading created Excel
Local $iPing = Ping("http://blogsearch.google.co.in/ping?url="$username"&btnG=Submit+Blog&hl=en", 2500)
If $iPing Then ; If a value greater than 0 was returned then display the following message.
MsgBox(0, "STATUS", "Ping Successful", 1)
Else
MsgBox(0, "STATUS", "ERROR", 1)
EndIf
Next
将变量连接到字符串:
$id = 21622809
MsgBox(0, '', "http://example.com/user/" & $id & "/blah_blah_blah")
或启用ExpandVarStrings
选项使用变量:
$id = 21622809
Opt("ExpandVarStrings", 1)
MsgBox(0, "", "http://example.com/user/$id$/blah_blah_blah")
如Teifun2所示,您只需要在引号或双引号之间写下文本,然后放置"&amp;"在上一个引用AD之间,这是这样:
"I am writing this between double quotes at line # " & $i_Nbr & ' with simple quotes!'
像Xenobiologist在对问题的评论中已经说过,这应该可以正常工作:
#include <Excel.au3>
$sFilePath1 = "D:Desktop1.xlsx"
$oExcel = _ExcelBookOpen($sFilePath1, 0)
For $i = 1 To 2 ;Loop
Local $username = _ExcelReadcell($oExcel, $i, 1) ;Reading created Excel
Local $iPing = Ping("http://blogsearch.google.co.in/ping?url="&$username&"&btnG=Submit+Blog&hl=en", 2500)
If $iPing Then ; If a value greater than 0 was returned then display the following message.
MsgBox(0, "STATUS", "Ping Successful" ,1)
Else
MsgBox(0, "STATUS", "ERROR" ,1)
EndIf
Next