Re: 請教vb.net 的偵測

看板Programming作者時間18年前 (2006/11/30 09:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
將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 ※ jiannrong@kkcity.com.tw ( ) 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
文章代碼(AID): #15RYrF00 (Programming)
文章代碼(AID): #15RYrF00 (Programming)