好文档 - 专业文书写作范文服务资料分享网站

Visual Basic程序设计教程实验答案

天下 分享 时间: 加入收藏 我要投稿 点赞

End Sub

5. Private Sub Text2_LostFocus()

Dim x As Integer, y As Integer, m As Integer, n As Integer m = Val(Text1.Text): n = Val(Text2.Text) y = n / 2 - m x = m - y

Label2.Caption = x Label3.Caption = y

If Label2.Caption < 0 Or Label3.Caption < 0 Then i = MsgBox(\数据错误,请重新输入\

Text1 = \Text1.SetFocus End If

If Val(Text2.Text) < 2 * Val(Text1.Text) Then

i = MsgBox(\脚数必须>=2倍的头数,请重新输入\Text2 = \Text2.SetFocus End If

If n Mod 2 <> 0 Then

i = MsgBox(\脚数必须是偶数\Text2 = \

Text2.SetFocus End If End Sub

6. Private Sub Command1_Click() Dim a As Single, b As Single, c As Single

a = Val(Text1.Text): b = Val(Text2.Text): c = Val(Text3.Text) If b ^ 2 - 4 * a * c >= 0 Then

Label5.Caption = Format((-b + Sqr(b ^ 2 - 4 * a * c)) / (2 * a), \

Label7.Caption = Format((-b - Sqr(b ^ 2 - 4 * a * c)) / (2 * a), \Else

Label5.Caption = Format((-b) / (2 * a), \Format(Sqr(Abs(b ^ 2 - 4 * a * c)) / (2 * a), \Label7.Caption = Format((-b) / (2 * a), \Format(Sqr(Abs(b ^ 2 - 4 * a * c)) / (2 * a), \End If End Sub

Private Sub Command2_Click() Text1 = \

Text2 = \Text3 = \Label5.Caption = \Label7.Caption = \End Sub 7. Dim n!

Private Sub Command1_Click() Text1.Text = \n = 0 Cls End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) If Chr(KeyAscii) <> \If Chr(KeyAscii) = \n = n + 1 End If

If Chr(KeyAscii) = \n = n - 1 End If Else If n = 0 Then

Print \括号配对成功\Else If n > 0 Then

Print \左括号多于右括号\个,按重置按钮,重新输入\End If If n < 0 Then

Print \右括号多于左括号\个,按\重置; \按钮,重新输入\End If End If End If End Sub

8. Private Sub Command1_Click() Select Case Text1.Text Case Is > 7, Is < 1

i = MsgBox(\请输入1-7之间的一个数\提示\Case \

Text2.Text = \Case \

Text2.Text = \

Case \

Text2.Text = \Case \

Text2.Text = \Case \

Text2.Text = \Case \

Text2.Text = \Case \

Text2.Text = \End Select End Sub

Private Sub Command2_Click() t = Text1.Text If t > 7 Or t < 1 Then

i = MsgBox(\请输入1-7之间的一个数\提示\Else

Text3.Text = Choose(t, \\End If End Sub

Visual Basic程序设计教程实验答案

EndSub5.PrivateSubText2_LostFocus()DimxAsInteger,yAsInteger,mAsInteger,nAsIntegerm=Val(Text1.Text):n=Val(Text2.Text)y=n/2-mx=m-yLabel2.Cap
推荐度:
点击下载文档文档为doc格式
9ltar92wii6k2th1y0un
领取福利

微信扫码领取福利

微信扫码分享