• 主页

# 帮我写个拼接字符串的函数吧，谢谢，不是简单的拼接啊，

xxmiaoyong126com 2010-07-02 01:04:09
nummtr=ubound(mtrarray(0,1),2)

If nummtr=0 Then sqlcus=" t1.customer as cus1"
If nummtr=1 Then sqlcus=" isnull(t1.customer,"&mtrarray(0,1)&".customer) as cus1"
If nummtr=2 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,"&mtrarray(0,2)&".customer)) as cus1"
If nummtr=3 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,"&mtrarray(0,3)&".customer))) as cus1"
If nummtr=4 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,isnull("&mtrarray(0,3)&".customer,"&mtrarray(0,4)&".customer)))) as cus1"
If nummtr=5 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,isnull("&mtrarray(0,3)&".customer,isnull("&mtrarray(0,4)&".customer,"&mtrarray(0,5)&".customer))))) as cus1"
If nummtr=6 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,isnull("&mtrarray(0,3)&".customer,isnull("&mtrarray(0,4)&".customer,isnull("&mtrarray(0,5)&".customer,"&mtrarray(0,6)&".customer)))))) as cus1"

...全文
52 点赞 收藏 4

4 条回复

xxmiaoyong126com 2010-07-02

xxmiaoyong126com 2010-07-02
[Quote=引用 2 楼 shan1119 的回复:]

VB code
nummtr=ubound(mtrarray(0,1),2)

function getSql(nummtr as integer, mtrarray() as string) as string
dim p,flg

p="t1.customer"
flg=true
for i=0 to nummtr-1
if isnull(p……
[/Quote]

shan1119 2010-07-02
``````nummtr=ubound(mtrarray(0,1),2)

function getSql(nummtr as integer, mtrarray() as string) as string
dim p,flg

p="t1.customer"
flg=true
for i=0 to nummtr-1
if isnull(p) and flg then
p=mtrarray(0,nummtr)
else
flg=false
end if
next
getSql= p & " as cus1"
end function

sqlcus=getSql(nummtr,mtrarray)``````

xxmiaoyong126com 2010-07-02
If nummtr=0 Then sqlcus=" t1.customer as cus1"
If nummtr=1 Then sqlcus=" isnull(t1.customer,"&mtrarray(0,1)&".customer) as cus1"
If nummtr=2 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,"&mtrarray(0,2)&".customer)) as cus1"
If nummtr=3 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,
"&mtrarray(0,3)&".customer))) as cus1"
If nummtr=4 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,
isnull("&mtrarray(0,3)&".customer,"&mtrarray(0,4)&".customer)))) as cus1"
If nummtr=5 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,
isnull("&mtrarray(0,3)&".customer,isnull("&mtrarray(0,4)&".customer,"&mtrarray(0,5)&".customer))))) as cus1"
If nummtr=6 Then sqlcus=" isnull(t1.customer,isnull("&mtrarray(0,1)&".customer,isnull("&mtrarray(0,2)&".customer,
isnull("&mtrarray(0,3)&".customer,isnull("&mtrarray(0,4)&".customer,
isnull("&mtrarray(0,5)&".customer,"&mtrarray(0,6)&".customer)))))) as cus1"

ASP

2.8w+

ASP即Active Server Pages，是Microsoft公司开发的服务器端脚本环境。