Vbscript 使用经典asp将字符串分块

Vbscript 使用经典asp将字符串分块,vbscript,split,asp-classic,chunks,Vbscript,Split,Asp Classic,Chunks,我得到了一个分隔值列表(a,b,c,d,e,f,g,h,…) 我想把它们分成5块,像(a,b,c,d,e)(f,g,h,i,j)。。。。 有人能帮我用经典asp中的代码吗 arr = Split(messto, ",") ' convert to array totalemails = UBound(arr) ' total number of emails if totalemails mod 5 = 0 then totalloops = int(totalemails/5)

我得到了一个分隔值列表(a,b,c,d,e,f,g,h,…) 我想把它们分成5块,像(a,b,c,d,e)(f,g,h,i,j)。。。。 有人能帮我用经典asp中的代码吗

arr = Split(messto, ",") ' convert to array
totalemails = UBound(arr) ' total number of emails

if totalemails mod 5 = 0 then
    totalloops = int(totalemails/5) 
    else
    totalloops = int(totalemails/5) + 1
end if

x = 0 
y = 0
b = 0
for x = 0 to totalloops  


    for counter = (5* x)  to ((b+5)-1)
        if Trim(arr(counter)) <> "" and isnull(trim(arr(counter))) = false then 

        response.Write(Trim(arr(counter)))
        response.Write(counter & "<br>")
        mymssto =  mymssto & Trim(arr(counter)) & ","
        response.Write(mymssto)

        end if  

    next
arr=Split(messto,“,”)转换为数组
totalemails=UBound(arr)'电子邮件总数
如果TotalMod 5=0,则
TotalOOPS=int(totalemails/5)
其他的
TotalOOPS=int(totalemails/5)+1
如果结束
x=0
y=0
b=0
对于x=0到0
对于计数器=(5*x)到((b+5)-1)
如果Trim(arr(counter))“”和isnull(Trim(arr(counter)))=false,则
响应。写入(微调(arr(计数器)))
响应。写入(计数器&“
”) mymssto=mymssto和微调(arr(计数器))和“,” 响应。写入(mymssto) 如果结束 下一个
您想用它来实现这一点,它的功能非常强大,而且没有得到充分利用

下面是一个基于问题代码的简单示例

<%
Dim mumberToGroupBy: numberToGroupBy = 5
Dim index, counter, arr, messto

messto = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q"
arr = Split(messto, ",") ' convert to array

For counter = 0 To UBound(arr)
  'Can't divide by 0 so we need to make sure our counter is 1 based.
  index = counter + 1
  Call Response.Write(Trim(arr(counter)))
  'Do we have any remainder in the current grouping?
  If index Mod numberToGroupBy = 0 Then Response.Write("<br>")
Next
%>

有用的链接
  • (详细说明
    Mod()
    的使用)
使用