看板Programming
标 题Re: 请教vb.net 的侦测
发信站月光海洋BBS (Thu Nov 30 08:32:51 2006)
转信站ptt!ctu-reader!news.nctu!mobbs
将Console.ReadLine()用一个变数去接
例
strReturn=Console.ReadLine
If IsNumeric(strReturn) Then
Dim decValue = CType(strReutrn,Decimal)
'将decValue转成整数,并与原本比较,如果相等表示此数就是整数
If CType(decValue,Integer)=decvalue Then
grade(i)=decvalue
End If
End If
※ [email protected] ( ) wrote:
> Dim grade() As Integer = New Integer(9) {}
> Dim i, total As Integer
> total = 0
> For i = 0 To 8
> grade(i) = InputBox("请输入" & i + 1 & "学生成绩", "共有九笔")
> 'Console.Write("请输入{0:D2}位学生的成绩:", i + 1)
> 'grade(i) = Console.ReadLine()
> total += grade(i) '计算成绩总合
> Next
> MsgBox("学生总平均为" & total / 9)
> 请教一下,我如何在inputbox这里侦测 如果输入的不是整数 他就不会储存到阵列里呢
> 谢谢
--
◣ ███ ███ ☆ Post by minmin
◢█ ▉▉█ █▇█ ★ From 139.223.35.31
◥█◤ ﹉ ﹍ ﹋ 月光海洋BBS 《mobbs.stut.edu.tw》 163.26.220.130