2015-01-14 157 views
0

我在經典ASP下面的代碼:字符串數組與經典ASP

Dim objHttp, strQuery 
strQuery = "https://geoip.maxmind.com/f?333l=2112212&i=" & ipaddress 
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP") 
objHttp.open "GET", strQuery, false 
objHttp.send 

Response.Write objHttp.ResponseText 
Set objHttp = Nothing 

這是從一個的MaxMind API來獲取他的每一個IP用戶的城市/ ZIP。它的工作,但我得到很長的一行:

美國,加利福尼亞州,洛杉磯,90068,34.134499,-328.190804,673,818, 「AT &牛逼U型詩句」

任何想法如何我能打破這條線並從中獲得某些價值嗎?

+0

[檢查拆分功能](http://msdn.microsoft.com/zh-cn/library/0764e5w5%28v= vs.84%29.aspx) – SearchAndResQ

回答

6
theArray = Split(objHttp.ResponseText,",") 

for i=0 to uBound (theArray) 
    response.write theArray(i) 
next 

試試看。如果字符串總是處於相同格式,則可以簡單地通過說theArray(3)