2011-05-19 49 views
0

我需要從現有變量中取出各種長度的郵政編碼,並在適當時將它們截斷爲5個字符。截取vbscript變量的技巧

此代碼是否工作?如果不是,我該如何做到這一點?

StateZip = split(splitAddr(1), " ") 
StateZip = left(StateZip, 5) 
+1

通過[文檔】(http://msdn.microsoft.com/en-us/library/sk3xcs8k(VS.85)的.aspx)'StateZip =左(StateZip,5)'應工作。你嘗試過運行它嗎? – 2011-05-19 15:17:31

回答

1
splitAddr = "123456 12345 1234" 
StateZip = split(splitAddr," ") 
For i = LBound(StateZip) To UBound(StateZip) 
    StateZip(i) = left(StateZip(i), 5) 
    WScript.Echo StateZip(i) 
Next