Convert string to integer .asp classic

前端 未结 1 558
忘掉有多难
忘掉有多难 2021-01-04 23:55

I have the following code, comments detail what should happen:

averageNum = myArray2(0) \'assign variable
response.wri         


        
1条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-05 00:33

    I would be checking that the value of myArray2(0) is an integer as you're expecting. Simple way to do this is using IsNumeric() which returns a Boolean value.

    Something like this;

    averageNum = myArray2(0) 'assign variable
    'Check numeric value assume 0 if not numeric.
    If Len(averageNum) > 0 And IsNumeric(averageNum) Then
      averageNum = CInt(averageNum) 
    Else
      averageNum = 0
    End If
    

    0 讨论(0)
提交回复
热议问题