看板 Visual_Basic 關於我們 聯絡資訊
就是請使用者輸入兩個邊長在詢問是否包含斜邊 再算出第三邊長 如果按有包含的話那個迴圈是可以執行的 問題出在如果按下沒有包含的時候是會卡住的 程式就當了@@" 所以請問一下這是什麼問題? 程式碼如下; Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b As Double Dim temp As Double a = Val(InputBox("第一個邊長:")) b = Val(InputBox("第一個邊長:")) If b > a Then temp = a a = b b = temp End If Dim x As DialogResult Dim c As Integer = 0 x = MessageBox.Show("是否包含斜邊長?", "斜邊", MessageBoxButtons.YesNo) If x.Yes Then Do Until a ^ 2 = b ^ 2 + c ^ 2 c = c + 1 Loop Else Do Until c ^ 2 = a ^ 2 + b ^ 2 c = c + 1 Loop End If Label1.Text = c End Sub -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.142.19