嵩天 python語言程序設計基礎(vb語言程序設計是什么)

摘要: 您好,今天小編胡舒來為大家解答以上的問題。嵩天 python語言程序設計基礎,vb語言程序設計是什么相信很多小伙伴還不知道,現在讓我們一起來看看吧!1、Option Explici...

您好,今天小編胡舒來為大家解答以上的問題。嵩天 python語言程序設計基礎,vb語言程序設計是什么相信很多小伙伴還不知道,現在讓我們一起來看看吧!

1、Option ExplicitPrivate Sub Command1_Click() Dim a As Integer Dim b As Integer Dim c As Integer Static r As Integer Static ct As Integer Static n As Integer If Command1.Caption = "開始" Or Command1.Caption = "下一題" Then a = Int(Rnd() * 90) + 10 b = Int(Rnd() * 90) + 10 c = Int(Rnd() * 4) Select Case c Case 0 Label2.Caption = a & " + " & b & " = ?" r = a + b Case 1 If a < b Then r = a a = b b = r End If Label2.Caption = a & " - " & b & " = ?" r = a - b Case 2 a = Int(Rnd() * 100) + 1 b = Int(Rnd() * 100) + 1 If a < b Then r = a a = b b = r End If r = a b If r = 0 Then r = 1 a = b * r a = r Label2.Caption = a & " * " & b & " = ?" r = a * b Case 3 a = Int(Rnd() * 100) + 1 b = Int(Rnd() * 100) + 1 If a < b Then r = a a = b b = r End If r = a b If r = 0 Then r = 1 a = b * r Label2.Caption = a & " / " & b & " = ?" r = a b End Select Command1.Caption = "提交答案" Label3.Caption = "" Text1.Text = "" Else If Text1.Text = "" Then MsgBox "請輸入答案", vbCritical Exit Sub End If Label2.Caption = Left(Label2.Caption, Len(Label2.Caption) - 1) & Text1.Text n = n + 1 If Val(Text1.Text) = r Then Label3.Caption = "√" Label3.ForeColor = vbBlue ct = ct + 1 Else Label3.Caption = "×" & "(正確答案:" & r & ")" Label3.ForeColor = vbRed End If List1.AddItem Label2.Caption & Label3.Caption Command1.Caption = "下一題" Label1.Caption = "正確率" & Format(ct / n, "00.0%") End IfEnd SubPrivate Sub Form_Load() Command1.Caption = "開始" Label1.Caption = "正確率:0%" Label2.Caption = "點開始按鈕答題" Label3.Caption = "" Text1.Text = "" Randomize TimerEnd Sub不明白的加百度HI給你發代碼。

本文就為大家分享到這里,希望小伙伴們會喜歡。