2014-02-07 53 views
0

我有下面的腳本,但沒有成功執行它沒有錯誤。我想把一個變量放到一個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 
    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 
+1

您好,歡迎來SO。請添加一些更多的細節,比如您獲得的錯誤和期望的輸出。 – thomaux

+0

而不是「$ username」,它必須從excel中獲取url並ping整個url。 – user3282817

+0

本地$ iPing =平( 「http://blogsearch.google.co.in/ping?url=」 $用戶名 「和btnG =提交+博客&HL = EN」,2500)本地$ iPing =平(「HTTP:// blogsearch.google.co.in/ping?url=www.facebook.com&btnG=Submit+Blog&hl=en「,2500) – user3282817

回答

0

像Xenobiologist已經在註釋中的問題時說,這應該只是正常工作:

#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 
0

由於Teifun2表明,你只需要編寫引號或雙引號之間的文本,然後把「&」最後的報價廣告有何變化,是這樣的:

"I am writing this between double quotes at line # " & $i_Nbr & ' with simple quotes!' 
0

,可以串聯變量字符串

$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")