String 字符串中的变量
我有下面的脚本,但是没有错误就无法成功地执行它。我想将一个变量放入URL并ping该URLString 字符串中的变量,string,variables,ping,autoit,String,Variables,Ping,Autoit,我有下面的脚本,但是没有错误就无法成功地执行它。我想将一个变量放入URL并ping该URL #include <Excel.au3> $sFilePath1 = "D:\Desktop\1.xlsx" $oExcel = _ExcelBookOpen($sFilePath1, 0) For $i = 1 To 2 ; Loop Local $username = _ExcelReadcell($oExcel, $i, 1) ;Reading created Excel
#include <Excel.au3>
$sFilePath1 = "D:\Desktop\1.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
#包括
$sFilePath1=“D:\Desktop\1.xlsx”
$oExcel=\u ExcelBookOpen($sFilePath1,0)
对于$i=1到2;环
本地$username=\uExcelReadCell($oExcel,$i,1);阅读创建的Excel
本地$iPing=Ping(“http://blogsearch.google.co.in/ping?url=“$username”&btnG=Submit+Blog&hl=en”,2500)
如果是$iPing那么;如果返回的值大于0,则显示以下消息。
MsgBox(0,“状态”,“Ping成功”,1)
其他的
MsgBox(0,“状态”,“错误”,1)
恩迪夫
下一个
正如异种生物学家在对这个问题的评论中所说的,这应该很好:
#include <Excel.au3>
$sFilePath1 = "D:\Desktop\1.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
#包括
$sFilePath1=“D:\Desktop\1.xlsx”
$oExcel=\u ExcelBookOpen($sFilePath1,0)
对于$i=1到2;环
本地$username=\uExcelReadCell($oExcel,$i,1);阅读创建的Excel
本地$iPing=Ping(“http://blogsearch.google.co.in/ping?url=“&$username&”&btnG=Submit+Blog&hl=en”,2500)
如果是$iPing那么;如果返回的值大于0,则显示以下消息。
MsgBox(0,“状态”,“Ping成功”,1)
其他的
MsgBox(0,“状态”,“错误”,1)
恩迪夫
下一个
正如Teifun2所示,您只需在引号或双引号之间写入文本,然后在最后一个引号和变量之间加上“&”,如下所示:
"I am writing this between double quotes at line # " & $i_Nbr & ' with simple quotes!'
可以将变量连接到字符串
$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")
大家好,欢迎来到SO。请添加更多详细信息,如您正在获取的错误和所需的输出。它必须从excel获取url并ping整个url,而不是“$username”。Local$iPing=ping(“,2500)Local$iPing=ping(“,2500)您试图实现什么?Ping返回域的往返时间。Url指令(您的变量)与
Ping()
无关;它只需将ping返回到blogsearch.google.co.in
。HTTP和ICMP是不同的概念。