从数据库中提取值,并在打印前更改值

时间:2014-01-13 20:09:45

标签: vbscript asp-classic

好的,所以我差点为我运行的电子商务商店编写模块。我从数据库中提取一个值:

shipChange = rs("ordShipType")

response.write rs("ordID") & vbTab & rs("ordTrackNum") & vbTab &  shipChange & vbTab & OrderDate & vbCrlf

我需要检测shipChange的值是否= UPS Ground,如果是,我需要在打印前将其更改为UPS,如果值为USPS First Class,我需要将其更改为USPS。结果会吐入制表符分隔的文本文件中,并且会有多个值被拉出,因此需要继续检查,直到读取并更改了所有值。

2 个答案:

答案 0 :(得分:2)

使用Select Case确定更改内容的方式以及Split获取UPS *的第一个“字”。

Option Explicit

Dim shipChange
For Each shipChange In Array("UPS Ground", "USPS First Class", "Reitender Bote")
   WScript.Stdout.Write shipChange
   Select Case shipChange
     Case "UPS Ground", "USPS First Class"
       shipChange = Split(shipChange)(0)
     Case "Reitender Bote"
       shipChange = "Horse"
     Case Else
       shipChange = "????"
   End Select
   WScript.Echo " =>", shipChange
Next

输出:

cscript 21100431.vbs
UPS Ground => UPS
USPS First Class => USPS
Reitender Bote => Horse

答案 1 :(得分:1)

shipChange = Replace(rs("ordShipType"), "USPS First Class", "USPS")
shipChange = Replace(shipChange, "UPS Ground", "UPS")