台灣最大程式設計社群網站
線上人數
1011
 
會員總數:244578
討論主題:188713
歡迎您免費加入會員
討論區列表 >> VB.NET >> Visual Studio 2015 if msg 的問題
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
Visual Studio 2015 if msg 的問題
價值 : 5 QP  點閱數:219 回應數:1

樓主

KZ1
門外漢
0 1
4 0
發送站內信

怎樣可以不會顯示2次出來
https://www.youtube.com/watch?v=gQrZLHKKJ_I


Dim x As String = TextBox1.Text
Dim a As String = TextBox2.Text

If Not IsNumeric(TextBox1.Text) Or Not IsNumeric(TextBox2.Text) Then
MsgBox("In the TextBox1 Cannot enter characters other than numbers ", MsgBoxStyle.Critical, "Test Error!!")
ElseIf (x < 1) Or (x > 100) Or (a < 1) Or (a > 100) Then
MsgBox("in the TextBox1 text error! You can only input between 1-100 ", MsgBoxStyle.Critical, "Test Error!!")

End If
If Not IsNumeric(TextBox2.Text) Then
MsgBox("In the TextBox2 Cannot enter characters other than numbers ", MsgBoxStyle.Critical, "Test Error!!")
ElseIf (a < 1) Or (a > 100) Then
MsgBox("In the TextBox2 text error! You can only input between 1-100 ", MsgBoxStyle.Critical, "Test Error!!")


End If

End Sub

雖然好好像下面寫可以解決問題,但我要他知道他是錯那一個txt



Dim name As String = txtname.Text
Dim test As String = txttext.Text
Dim quiz As String = txtquiz.Text
Dim project As String = txtproject.Text
Dim exam As String = txtexam.Text
Dim tqp As Double = (test * 0.5) + (project * 0.3) + (quiz * 0.2)
Dim camark As String = txtcamark.Text
Dim CAE As Double = exam * 0.6

If IsNumeric(txtname.Text) Then
MsgBox("In the Name Can only be entered in English ", MsgBoxStyle.Critical, "Name Error!!")

ElseIf Not IsNumeric(txttext.Text) Or Not IsNumeric(txtquiz.Text) Or Not IsNumeric(txtproject.Text) Or Not IsNumeric(txtexam.Text) Then
MsgBox("Cannot enter characters other than numbers ", MsgBoxStyle.Critical, "Test Error!!")

ElseIf (test < 1) Or (test > 100) Or (quiz < 1) Or (quiz > 100) Or (project < 1) Or (project > 100) Or (exam < 1) Or (exam > 100) Then
MsgBox("text error! You can only input between 1-100 ", MsgBoxStyle.Critical, "Test Error!!")

ElseIf (test * 0.5) + (project * 0.3) + (quiz * 0.2) Then
txtcamark.Text = tqp

ElseIf exam * 0.6 Then
txtmodulemarks.Text = CAE

End If
End Sub


然後為什麼exam 沒有顯示出來?


搜尋相關Tags的文章: [ ] , [ ] ,
本篇文章發表於2018-12-05 00:15
別忘捐VP感謝幫助你的人 新手會員瞧一瞧
1樓
回應

培根
檢舉此回應
以你寫的程式碼+上我的思考方是,你第一行 "Or Not IsNumeric(TextBox2.Text)"是多餘的

ElseIf exam * 0.6 Then
txtmodulemarks.Text = CAE

沒顯示感覺很正常啊
因為你前面的限制,造成 (test * 0.5) + (project * 0.3) + (quiz * 0.2) 永遠成立
你乾卻直接 txtmodulemarks.Text = exam * 0.6 比較快

這是我目前理解的
本篇文章回覆於2018-12-05 10:00
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.