vb百科园教育程序题答案

vb百科园教育程序题答案,第1张

书名:VisualBasic程序设计简明教程实验指导与习题解答(2作者:王晓东主编出版社:水利水电出版社原价:出版日期:2009-1-1ISBN:9787508462394字数:页数:196印次:版次:1纸张:开本:16开编辑推荐本书采用“任务驱动”的编写方式,引入案例和启发式教学方法;提供电子教案,案例素材等教学资源,教材立体化配套;满足高等院校应用型人才培养的需要。内容提要本书是与《VisualBasic程序设计简明教程》一书配套使用的实验指导。全书共6章,内容包括VisualBasic语言集成开发环境,程序调试方法,VisualBasic语言程序设计课程的典型实验项目,《VisualBasic程序设计简明教程》一书的习题参考解答以及模拟试题。书中的实验和开发示例都进行了验证,习题解答全部在VisualBasic6.0环境下调试通过。实验和习题解答内容翔实,注重基础,强调实践。不仅密切配合了VisualBasic语言程序设计课程的理论教学,而且具有较高的实用价值。本教材是学习VisualBasic语言和实践上机的必备参考书,适合高等学校本专科学生使用,也可用作广大软件开发人员以及工程技术人员的参考用书。目录序前言第1章VisualBasic6.0集成开发环境1.1VisualBasic6.0简介1.2VisualBasic6.0集成开发环境1.2.1启动VisualBasic6.0集成开发环境1.2.2VisualBasic6.0主界面1.3创建一个简单的VisualBasic6.0应用程序第2章VisualStudio2005集成开发环境2.1VisualStudio2005简介2.2VisualStudio2005集成开发环境2.2.1VisualStudio2005集成开发环境的启动2.2.2VisualBasic2005集成开发环境2.3创建一个简单的VisualBasic2005应用程序第3章程序调试与异常处理3.1VisualBasic错误种类3.1.1语法错误3.1.2运行时错误3.1.3逻辑错误3.2程序调试3.2.1VisualBasic调试工具3.2.2VisualBasic工作模式3.2.3VisualBasic的运行方式3.2.4调试窗口3.3异常处理第4章实验指导实验一VisualBasic语言环境实验实验二简单程序设计实验三选择程序设计实验四循环程序设计实验五数组程序设计实验六过程程序设计实验七界面设计实验八文件实验九数据库应用实验十综合程序设计第5章习题解答习题一习题二习题三习题四习题五习题六习题七习题八习题九第6章模拟试题模拟试题(一)模拟试题(一)参考答案模拟试题(二)模拟试题(二)参考答案模拟试题(三)模拟试题(三)参考答案模拟试题(四)模拟试题(四)参考答案模拟试题(五)模拟试题(五)参考答案

上网收费:'Option Explicit

Dim t As Integer, f As Single, x As String

Private Sub Form_Load()

Text1.Text = ""

Label2 = ""

End Sub

Private Sub Command1_Click()

If Text1.Text = "" Then

Text1.SetFocus

MsgBox "请输入上网时间"

Exit Sub

End If

t = Val(Text1.Text)

If t <120 Then

f = 0.06 * t + 2

Else

f = 0.06 * t * 0.85

End If

x = Str$(f) + "元"

Label2.Caption = x

Text1.SetFocus

End Sub

三角函数:Private Sub Form_Load()

Text1.Text = ""

Label7.Caption = ""

End Sub

Private Sub Command1_Click()

Dim a, b As Double

Dim c As String

'Form2.Cls

If Text1.Text = "" Then

Text1.SetFocus

MsgBox "请输入计算数据"

Exit Sub

End If

If Option4.Value = True Then

b = Val(Text1.Text) * 3.14 / 180

ElseIf Option5.Value = True Then

b = Val(Text1.Text)

End If

If Option1.Value = True Then

a = Sin(b)

c = "sin(" &Text1.Text &")="

ElseIf Option2.Value = True Then

a = Cos(b)

c = "Cos(" &Text1.Text &")="

ElseIf Option3.Value = True Then

a = Tan(b)

c = "Tan(" &Text1.Text &")="

End If

a = Round(a, 6)

a = Format(a, "0.##########")

'If Left(a, 1) = "." Then

'a = "0" &a

'ElseIf Left(a, 2) = "-." Then

'a = "-0" &Right(a, Len(a) - 1)

'End If

Label7.Caption = c &a

End Sub

打印几何图形:Private Sub Form_Load()

Picture1.FontSize = 16

End Sub

Private Sub Image1_Click()

Picture1.CurrentX = 0

Picture1.CurrentY = 0

For i = 0 To 5

Picture1.Print Tab(8 - i)

For j = 1 To 2 * i + 1

Picture1.Print "*"

Next j

Print

Next i

End Sub

Private Sub Image2_Click()

Picture1.CurrentX = 0

Picture1.CurrentY = 0

For i = 0 To 5

Picture1.Print Tab(12 + i)

For j = 1 To 6

Picture1.Print "*"

Next j

Print

Next i

End Sub

计算矩形周长面积:

Private Sub Form_Load()

Text1.Text = ""

Text2.Text = ""

Label3.Caption = ""

End Sub

Private Sub Command1_Click()

If Text1.Text = "" Then

Text1.SetFocus

MsgBox "请输入矩形的长"

Exit Sub

End If

If Text2.Text = "" Then

Text2.SetFocus

MsgBox "请输入矩形的宽"

Exit Sub

End If

If Option1.Value = False And Option2.Value = False Then

MsgBox "请选择计算类型"

Exit Sub

End If

s = Val(Text1.Text) * Val(Text2.Text)

l = 2 * (Val(Text1.Text) + Val(Text2.Text))

If Option1 = True Then

Label3.Caption = Str(s)

ElseIf Option2 = True Then

Label3.Caption = Str(l)

End If

End Sub

Private Sub Command2_Click()

Label3.Caption = ""

End Sub

Private Sub Command3_Click()

End

End Sub

计算器:Dim jsff

Dim f_num As Single

Private Sub Form_Load()

f_num = 0

jsff = ""

Text1.Text = ""

End Sub

Private Sub js()

Select Case jsff

Case "+"

f_num = f_num + Val(Text1.Text)

Case "-"

f_num = f_num - Text1.Text

Case "*"

f_num = f_num * Text1.Text

Case "/"

f_num = f_num / Text1.Text

Case "/"

f_num = f_num / Text1.Text

End Select

End Sub

Sub Command1_Click()'+

If Text1.Text = "" Then

Text1.SetFocus

Exit Sub

End If

If jsff = "" Then

f_num = Val(Text1.Text)

Else

js

End If

jsff = "+"

Text1.Text = ""

Text1.SetFocus

End Sub

Private Sub Command2_Click()

If Text1.Text = "" Then

Text1.SetFocus

Exit Sub

End If

If jsff = "" Then

f_num = Val(Text1.Text)

Else

js

End If

jsff = "-"

Text1.Text = ""

Text1.SetFocus

End Sub

Private Sub Command3_Click()

If Text1.Text = "" Then

Exit Sub

End If

If jsff = "" Then

f_num = Val(Text1.Text)

Else

js

End If

jsff = "*"

Text1.Text = ""

Text1.SetFocus

End Sub

Private Sub Command4_Click()

If Text1.Text = "" Then

Exit Sub

End If

If jsff = "" Then

f_num = Val(Text1.Text)

Else

js

End If

jsff = "/"

Text1.Text = ""

Text1.SetFocus

End Sub

Private Sub Command6_Click()

If Text1.Text = "" Then

Text1.SetFocus

Exit Sub

End If

x = Round(Sin(Val(Text1.Text)), 4)

If Left(x, 2) = "-." Then

x = "-0" &Right(x, Len(x) - 1)

ElseIf Left(x, 1) = "." Then

x = "0" &x

End If

Text1.Text = x

End Sub

Private Sub Command7_Click()

If Text1.Text = "" Then

Text1.SetFocus

Exit Sub

End If

x = Format(Round(Cos(Val(Text1.Text)), 4), "0.##########")

Text1.Text = x

End Sub

Private Sub Command8_Click()

If Val(Text1.Text) <0 Then

MsgBox "请不要对负数做开方运算"

Text1.SetFocus

Exit Sub

End If

x = Sqr(Val(Text1.Text))

If Left(x, 1) = "." Then x = "0" &x

Text1.Text = x

End Sub

Private Sub Command9_Click()

If Text1.Text = 0 Then

MsgBox "请不要对0做倒数运算"

Text1.SetFocus

Exit Sub

End If

x = Val(1 / Text1.Text)

If Left(x, 2) = "-." Then

x = "-0" &Right(x, Len(x) - 1)

ElseIf Left(x, 1) = "." Then

x = "0" &x

End If

Text1.Text = x

End Sub

Private Sub Command5_Click()

If Text1.Text = "" And jsff = "" Then

Text1.SetFocus

Exit Sub

End If

If Text1.Text = "" And jsff = "+" Then

MsgBox "请输入加数"

Text1.SetFocus

Exit Sub

ElseIf Text1.Text = "" And jsff = "-" Then

MsgBox "请输入减数"

Text1.SetFocus

Exit Sub

ElseIf Text1.Text = "" And jsff = "*" Then

MsgBox "请输入乘数"

Text1.SetFocus

Exit Sub

ElseIf Text1.Text = "" And jsff = "/" Then

MsgBox "请输入除数"

Text1.SetFocus

Exit Sub

ElseIf Text1.Text = 0 And jsff = "/" Then

MsgBox "请不要用0做除数"

Text1.SetFocus

Exit Sub

End If

js

x = f_num

If Left(x, 2) = "-." Then

x = "-0" &Right(x, Len(x) - 1)

ElseIf Left(x, 1) = "." Then

x = "0" &x

End If

Text1.Text = x

jsff = ""

f_num = 0

End Sub

Private Sub Command10_Click()

Text1.Text = ""

f_num = 0

jsff = ""

Text1.SetFocus

End Sub

Private Sub Text1_Change()

End Sub

检查体重:

'Option Explicit

Dim bz

Private Sub Form_Load()

bz = 0

End Sub

Private Sub Command1_Click()

If Text1.Text = "" Then

Text1.SetFocus

MsgBox "请输入身高"

Exit Sub

End If

If Text2.Text = "" Then

Text2.SetFocus

MsgBox "请输入体重"

Exit Sub

End If

If Option1.Value = False And Option2.Value = False Then

MsgBox "请选择被检测者性别"

Exit Sub

End If

If Option1 = True Then

x = Val(Text1.Text) - 100

ElseIf Option2 = True Then

x = Val(Text1.Text) - 105

End If

If Val(Text2.Text) >x Then

Label3.Caption = "体重超标"

Timer1.Enabled = True

Else

Label3.Caption = "体重正常"

Image2.Picture = Image1.Picture

End If

End Sub

Private Sub Timer1_Timer()

If bz = 1 Then

Image2.Picture = Image1.Picture

bz = 0

ElseIf bz = 0 Then

Image2.Picture = Image3.Picture

bz = 1

End If

End Sub

Private Sub Command2_Click()

Label3.Caption = ""

Timer1.Enabled = False

Image2.Picture = Image3.Picture

End Sub

Private Sub Command3_Click()

End

End Sub

小广告:Dim bz

Private Sub Form_Load()

bz = 0

End Sub

Private Sub Command1_Click()

Label1.Visible = True

Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()

If Label1.Left <0 Then

Label1.Left = 6000

Else

Label1.Left = Label1.Left - 150

End If

If bz = 1 Then

Image3.Picture = Image1.Picture

bz = 0

ElseIf bz = 0 Then

Image3.Picture = Image2.Picture

bz = 1

End If

End Sub

诊断处方:Private Sub Form_Load()

Combo1.AddItem "轻微红肿"

Combo1.AddItem "肿痛"

Combo1.AddItem "化脓"

Combo1.Text = Combo1.List(0) '设置combo1的默认选择

Combo2.AddItem "轻度"

Combo2.AddItem "中度"

Combo2.AddItem "重度"

Combo2.AddItem "剧烈"

Combo2.AddItem "尖锐"

Combo2.Text = Combo2.List(0) '设置combo2的默认选择

Combo3.AddItem "36度"

Combo3.AddItem "37度"

Combo3.AddItem "38度"

Combo3.AddItem "39度"

Combo3.AddItem "40度"

Combo3.Text = Combo3.List(0) '设置combo3的默认选择

Combo4.AddItem "干咳"

Combo4.AddItem "有痰"

Combo4.AddItem "早起咳"

Combo4.Text = Combo4.List(0) '设置combo4的默认选择

List1.AddItem "咽炎方" '设置列表框的可选项目

List1.AddItem "阿司匹林"

List1.AddItem "青霉素针剂"

List1.AddItem "感冒通"

List1.AddItem "维生素B"

List1.AddItem "维生素C"

List1.AddItem "喉片"

List1.Text = List1.List(0)

End Sub

Private Sub List1_DblClick()

List2.AddItem List1.Text

End Sub

Private Sub List2_DblClick()

List2.RemoveItem List2.ListIndex

End Sub

Private Sub Command1_Click()

Var$ = Combo1.Text + Combo2.Text + Combo3.Text + Combo4.Text

Select Case Var$

Case Is = "肿痛轻度38度干咳"

Text1.Text = "咽炎"

Case Is = "化脓中度39度早起咳"

Text1.Text = "扁桃体发炎"

Case Is = "化脓重度40度有痰"

Text1.Text = "肺炎"

Case Else

Text1.Text = "重选"

End Select

End Sub

Private Sub Command3_Click()

For i = 0 To List2.ListCount - 1

If i = List2.ListCount Then

Exit Sub

ElseIf List2.Selected(i) Then

List2.RemoveItem i

i = -1

End If

Next i

End Sub

Private Sub Command2_Click()

End

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11079241.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存