1
在JSON地理編碼GetResponse中,Microsoft提供的代碼使用函數返回結果。但是,我想使用該函數以外的結果,但之後我無法從函數內訪問數據。也許代碼可以更清楚地說明這一點:函數內的訪問變量
Dim geocodeRequest As New Uri(String.Format("http://dev.virtualearth.net/REST/v1/Locations?q={0}&key={1}", query, key))
Dim latlong_adress As BingMapsRESTService.Common.JSON.Location = Nothing
GetResponse(geocodeRequest, Function(x)
MsgBox(x.ResourceSets(0).Resources.Length & " result(s) found.")
latlong_adress = x.ResourceSets(0).Resources(0)
'Correct results:
MsgBox(latlong_adress.Confidence)
MsgBox(latlong_adress.EntityType)
MsgBox(latlong_adress.Point.Coordinates(0) & ", " & latlong_adress.Point.Coordinates(1))
Return 0
End Function)
'Empty: --> is nothing
If latlong_adress IsNot Nothing Then
MsgBox(latlong_adress.Confidence)
MsgBox(latlong_adress.EntityType)
MsgBox(latlong_adress.Point.Coordinates(0) & ", " & latlong_adress.Point.Coordinates(1))
End If
如何在響應後訪問響應中的數據?