2012-08-10 158 views
0

am有url .it包含querstring的值,像this.to拆分url並將查詢字符串值存儲在數組中.query字符串值在應用程序中不傳遞。 它來自另一個應用程序關於在字符串中使用vb.net的split命令

url 
---- 
http://.....?lead_id=152818&vendor_id=100001&list_id=1001&gmt_offset_now=0.00&phone_code=91&phone_number=9942321400&title=MR&first_name=Hari&middle_initial=Q&last_name=PUBLIC&address1=249+MUNDON+ROAD&address2=MALDON&address3=FL&city=44&state=TN&province=NO_PROVINCE&postal_code=600004&country_code=IN&gender=M&date_of_birth=0000-00-00&alt_phone=9942321400&[email protected]&security_phrase=nothing&comments=COMMENTS&user=22222&pass=test&campaign=OUTBOUND&phone_login=22222&original_phone_login=22222&phone_pass=test&fronter=22222&closer=22222&group=OUTBOUND&channel_group=OUTBOUND&SQLdate=2012-08-07+164931&epoch=1344338372&uniqueid=1344338352.12754&customer_zap_channel=&customer_server_ip=&server_ip=10.103.200.177&SIPexten=22222&session_id=8600062&phone=9942321400&parked_by=152818&dispo=N&dialed_number=9942321400&dialed_label=MAIN&source_id=10001&rank=1&owner=Southeast&camp_script=&in_script=&script_width=600&script_height=340&fullname=J.Hariharan&recording_filename=OUTBOUND_20120807-164911_22222_9942321400&recording_id=248601&user_custom_one=&user_custom_two=&user_custom_three=&user_custom_four=&user_custom_five=&preset_number_a=&preset_number_b=&preset_number_c=&preset_number_d=&preset_number_e=&preset_dtmf_a=&preset_dtmf_b=&session_name=1344338181_2222216466857" 



my question is i want to store the querystring values in an one dimensional string 
array. 


my code 
------- 
Dim strarr() As String 
    Dim s As String = "http://...../test.aspx?lead_id=152818&vendor_id=100001&list_id=1001&gmt_offset_now=0.00&phone_code=91&phone_number=9942321400&title=MR&first_name=Hari&middle_initial=Q&last_name=PUBLIC&address1=249+MUNDON+ROAD&address2=MALDON&address3=FL&city=44&state=TN&province=NO_PROVINCE&postal_code=600004&country_code=IN&gender=M&date_of_birth=0000-00-00&alt_phone=9942321400&[email protected]&security_phrase=nothing&comments=COMMENTS&user=22222&pass=test&campaign=OUTBOUND&phone_login=22222&original_phone_login=22222&phone_pass=test&fronter=22222&closer=22222&group=OUTBOUND&channel_group=OUTBOUND&SQLdate=2012-08-07+164931&epoch=1344338372&uniqueid=1344338352.12754&customer_zap_channel=&customer_server_ip=&server_ip=10.103.200.177&SIPexten=22222&session_id=8600062&phone=9942321400&parked_by=152818&dispo=N&dialed_number=9942321400&dialed_label=MAIN&source_id=10001&rank=1&owner=Southeast&camp_script=&in_script=&script_width=600&script_height=340&fullname=J.Hariharan&recording_filename=OUTBOUND_20120807-164911_22222_9942321400&recording_id=248601&user_custom_one=&user_custom_two=&user_custom_three=&user_custom_four=&user_custom_five=&preset_number_a=&preset_number_b=&preset_number_c=&preset_number_d=&preset_number_e=&preset_dtmf_a=&preset_dtmf_b=&session_name=1344338181_2222216466857" 
    strarr = s.Split("?") 
    Dim s1 As String = strarr(1) 
    Dim constr() As String 
    constr = s1.Split("&") 


but am not get correct result 


my result 
--------- 
list_id=1001 
gmt_offset_now=0.00 
phone_code=91 
phone_number=9942321400 


expected result 
--------------- 
    1001 
    0.00 
    91 
    9942321400 

回答

0

遍歷你的「構造」,並使用一個更分裂(用「=」)。結果可以存儲在List(String)中。

dim r as new list(of String) 
for each c in constr 
    r.add(c.split("=")(1)) 
next 

(像這樣)

要查看這個你應該列出「R」內的所有物品,所以你需要另一個用於。

for each item in r 
    console.writeline(item) 
next 

您也可以在第一個循環內做到這一點。

+0

Kuczynski在昏暗的聲明中出錯。像類型「列表」沒有定義 – vps 2012-08-10 06:51:42

+0

@Kuczynski我糾正它。但我不知道如何查看結果 – vps 2012-08-10 07:04:13

相關問題