doumei4964 2013-12-29 22:08
浏览 17
已采纳

翻译ASP功能

Can someone that is familiar with VB Script and ASP have a quick look at this function and tell me what it does so I can translate it to PHP? The beginning I can translate just fine, it's the for loop that it has. That's where I'm not sure what the code is doing exactly. The best I can do by looking at it is that it's going through the string strTemp it's creating a new sum adding the value of each digit. Thanks.

Function CheckSum (strTemp)
Dim i, intTemp

If Not IsNumeric(strTemp) Then
    CheckSum = 0
    Exit Function
End If

intTemp = 0

For i = 1 To Len(strTemp)
    intTemp = intTemp + CInt(Mid(strTemp, i, 1))
Next

CheckSum = intTemp
End Function
  • 写回答

3条回答 默认 最新

  • dongtan9066 2013-12-29 22:13
    关注

    Yes, you are correct - it is going through the string strTemp and summing the value of each digit. The function returns this 'checksum' value.

    Note that for this to work properly string will always have to digits 0-9 only, which ties up with the check near the top of the function.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试