简单Visual Basic(VB)编程问题,For语句、If语句、循环....题目如图,在线等,
Private Sub Command1_Click()
a = CInt(Text1.Text)
b = CInt(Text2.Text)
If b > a And b / a < 1.2 Then
Label3.Caption = "警告,您的车速超过限速!"
Else
If b / a >= 1.2 And b / a < 1.5 Then
Label3.Caption = "您的车速超过限速20%,处200元罚款,驾驶证记6分!"
Else
c = (b - a) / a * 100
y = c * 20
If y > 2000 Then y = 2000
Label3.Caption = "您的车速超过限速" & c & "%,处" & y & "元罚款,驾驶证记12分!"
End If
End If
End Sub
Private Sub Form_Load()
Label1.Caption = "限速"
Label2.Caption = "时速"
Label3.Caption = ""
Text1.Text = ""
Text2.Text = ""
Command1.Caption = "计算"
Command2.Caption = "清除"
Command3.Caption = "退出"
End Sub
Private Sub Command2_Click()
Call Form_Load
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command1_Click()
t = CInt(Text1.Text)
n = CInt(Text2.Text)
Sum = 0
y = 0
s$ = ""
For i = 1 To n
y = y * 10 + t
Sum = Sum + y
If i < 4 Then s$ = s$ & y & "+"
If i = n Then s$ = s$ & "...+" & y & "="
Next i
s$ = s$ & Sum
Label3.Caption = s$
End Sub
Private Sub Command2_Click()
Call Form_Load
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Label1.Caption = "t="
Label2.Caption = "n="
Label3.Caption = ""
Text1.Text = ""
Text2.Text = ""
Command1.Caption = "计算"
Command2.Caption = "清除"
Command3.Caption = "退出"
End Sub
辛苦了,虽然时间已经过了😂