【问题标题】:For next to add with classic asp为下一步添加经典 asp
【发布时间】:2015-01-07 15:10:06
【问题描述】:

为下一个“A to Z”获取结果。 进入; 5和数字6,我想补充。 我该怎么做。

for k = asc("A") to asc("Z")
response.write chr(k)
next

结果:

一个 乙 C .. Z

我想要 一种 乙 C .. Z 5 6

如( k = asc("A") 到 asc("Z") 加 "5" 和加"6" )

谢谢。

【问题讨论】:

  • 这个问题让我很困惑。您是在问如何遍历字母表或从 97 到 90?还有你要加“5”和“6”是什么,是k吗?
  • 我想再增加 2 个周期。变量

标签: for-loop asp-classic add next


【解决方案1】:

你不能真的有一个循环,只需添加单独的命令:

for k = asc("A") to asc("Z")
    response.write chr(k)
next
response.write "5"
response.write "6"

另一种选择是将所有 ASCII 数字存储在数组中,然后循环该数组:

Dim arrLetters(), x
ReDim arrLetters(-1)
For k=Asc("A") To Asc("Z")
    ReDim Preserve arrLetters(UBound(arrLetters) + 1)
    arrLetters(UBound(arrLetters)) = k
Next
ReDim Preserve arrLetters(UBound(arrLetters) + 1)
arrLetters(UBound(arrLetters)) = Asc("5")
ReDim Preserve arrLetters(UBound(arrLetters) + 1)
arrLetters(UBound(arrLetters)) = Asc("6")
For x=0 To UBound(arrLetters)
    k = arrLetters(x)
    response.write chr(k)
Next
Erase arrLetters

【讨论】:

  • 你好影子,好的,但我在循环中有另一个操作。再次在循环外进行交易,系统会很累。 for k = asc("A") to asc("Z") char(k) 与其他进程相关.... next
  • 谢谢影子。但; 5-6 没有出现。 response.write chr(k) 结果:ABCDEFGHIJKLMNOPQRSTUVWXYZ
  • 非常感谢,我的兄弟。现在好了。
【解决方案2】:
strString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ56"
For i=1 To Len(strString)
    Response.Write Mid(strString,i,1)
Next

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多