Random
类或 Math.Round
方法。使用 Random
类生成一个介于 1 到 100 之间的随机数:,,``asp,Dim rnd As New Random,Dim randomNumber As Integer = rnd.Next(1, 100),Response.Write(randomNumber),
`,,或者,使用
Math.Round 方法将小数转换为整数:,,
`asp,Dim number As Double = 42.6789,Dim roundedNumber As Integer = CInt(Math.Round(number)),Response.Write(roundedNumber),
``