Re: 請教vb.net 的偵測
將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
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章