版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实验 一 dim a20 as intergers10 as interger private sub button1_click. handles button1.click dim ijtextbox1.textquotquot for i1 to 20 aiintrnd101textbox1.textampaiampspace6-lenai jai10 select casej case 0to 5s5s51 case 9to 10 s9s91 case 6to 8 sjsj1 end select next i end subprivate sub button2_click.hand
2、lesbutton2.clicktextbox2.textquot0-59:quotamps5ampvbcrlftextbox2.textquot60-69:quotamps6ampvbcrlftextbox2.textquot70-79:quotamps7ampvbcrlftextbox2.textquot80-89:quotamps8ampvbcrlftextbox2.textquot90-100:quotamps9ampvbcrlf buton1 dim lamp100dim ijn nvaltextbox1.text for i1to n lampi0 next for i2 to n
3、 for ji to n if jmod i0 then if lampj1 then lampj0 else lampj1 end if end if next next输出 for j1 to n if lampj1 then label1.textquot 第 quotampsrjampquot盏 灯 亮 quotampvbnewline end if next end sub textbox1. if notisnumerictextbox1.textor valtextbox1.textlt0 then msgboxquot 请输入正整数 quot textbox1.textquot
4、quot textbox1.text.focus end if end sub实验二 SY2.1 Private Sub Button2_ClickByVal sender AsSystem.Object ByVal e As System.EventArgs Handles Button2.ClickDim f c c ValTextBox2.Text f 9 / 5 c 32TextBox1.Text Formatf quot.quot End Sub Sy2.2 Public Class Form1Dim RMB As Integer Dim Change Dol As Double P
5、rivate SubButton1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click TextBox1.Text quotquotTextBox2.Text quotquot TextBox3.Text quotquot End Sub PrivateSub Button4_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button4.Click End End Sub Private
6、 SubButton2_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button2.Click RMB ValTextBox1.TextChange ValTextBox2.Text Dol RMB / Change TextBox3.TextFormatDol quot.quot End Sub Private Sub Button3_ClickByValsender As System.Object ByVal e As System.EventArgs HandlesButton3.Click
7、 Dol ValTextBox3.Text Change ValTextBox2.Text RMBDol Change TextBox1.Text FormatRMB quotquot End Sub EndClass Sy2.3 Public Class Form1 Dim PI 3.1415926 Dim SquareCircle R Private Sub TextBox1_TextChangedByValsender AsSystem.Object ByVal e As System.EventArgs HandlesTextBox1.TextChanged If IsNumericT
8、extBox1.Text False OrTextBox1.Text quotquot Then MsgBoxquot 请输入数字 quot ElseIfTextBox1.Text lt 0 Then MsgBoxquot 请输入正数 quot End If EndSub Private Sub Button1_ClickByVal sender As System.ObjectByVal e As System.EventArgs Handles Button1.Click RValTextBox1.Text Square PI R R TextBox2.TextFormatSquarequ
9、ot.quot End Sub Private Sub Button2_ClickByVal sender AsSystem.Object ByVal e As System.EventArgs Handles Button2.ClickR ValTextBox1.Text Circle 2 PI R TextBox3.Text FormatCirclequot.quot End Sub End Class Sy2.4 Private Sub Form1_ClickByValsender As System.Object ByVal e As System.EventArgs HandlesM
10、yBase.Click If TextBox1.Text ltgt quothelloquot Then MsgBoxquot用户名不对 quot ElseIf IsNumericTextBox2.Text False ThenTextBox2.Text quotquot TextBox2.Focus ElseIf ValTextBox2.Text lt0 Then MsgBoxquot 请输入正数 quot ElseIf TextBox2.Text ltgtquot123456quot Then MsgBoxquot 密码错误 quot Else MsgBoxquot登录成功 quot En
11、d If End Sub 实验三 Sy3.2 Public Class Form1Private Sub Button2_ClickByVal sender As System.Object ByVal eAs System.EventArgs Handles Button2.Click TextBox1.Textquotquot TextBox2.Text quotquot TextBox3.Text quotquotTextBox4.Text quotquot TextBox1.Focus End Sub Private SubButton3_ClickByVal sender As Sy
12、stem.Object ByVal e AsSystem.EventArgs Handles Button3.Click End End Sub Private SubButton1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim x y z m xValTextBox1.Text y ValTextBox2.Text z ValTextBox3.Text If x gt yAnd y gt z Then m x x z z m ElseIf x gt y And y
13、 lt z And x lt z Then mx x y y m ElseIf x gt y And y lt z And x gt z Then m x x z z m m x x y ym ElseIf x lt y And y gt z And x gt z Then m x x z z m m z z y y m ElseIfx lt y And y gt z And x lt z Then m y y z z m ElseIf x lt y And y lt z ThenEnd If TextBox4.Text x amp quotltquot amp y amp quotltquo
14、t amp zEnd Sub End Class Sy3.3 Private Sub Button2_ClickByVal senderAs System.Object ByVal e As System.EventArgs HandlesButton2.Click TextBox1.Text quotquot TextBox2.Text quotquotTextBox3.Text quotquot TextBox4.Text quotquot End Sub PrivateSub Button3_ClickByVal sender As System.Object ByVal e AsSys
15、tem.EventArgs Handles Button3.Click End End Sub Private SubButton1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim m1 m2 m3 avg Dimrank As String m1 ValTextBox1.Text m2 ValTextBox2.Text m3ValTextBox3.Text avg m1 m2 m3 / 3 If avg lt 80 Then TextBox4.Textquot 无奖
16、 quot ElseIf avg gt 80 And avg lt 85 ThenTextBox4.Textquot 三等奖 quot ElseIf avg gt 85 And avg lt 90 Andm1 gt 80 And m2 gt 80 And m3 gt 80 Then TextBox4.Text quot 二等奖 quot ElseIf avg gt 90 Then TextBox4.Text quot 一等 奖 quot ElseIfm1 100 And m2 100 And m3 gt 85 ThenTextBox4.Text quot等奖 quot Elself ml 10
17、0 And m2 gt 85 And m3100 Then TextBox4.Textquot 一等奖 quot ElseIf m1 gt 85And m2 100 And m3 100 Then TextBox4.Text quot 一等奖 quot EndIf End Sub Sy3.4 Private Sub Button1_ClickByVal sender AsSystem.Object ByVal e As System.EventArgs Handles Button1.ClickDim DF NX DY DT SUM P SUM ValTextBox1.Text IfCheck
18、Box1.Checked Then DF 0.95 Else DF 1 End If IfRadioButton4.CheckedTrue ThenDT1ElseIfRadioButton5.CheckedTrueThen DT0.9EndIf IfRadioButton1.CheckedTrue Then NX 10DY0.05 ElseIfRadioButton2.CheckedTrue Then NX 20DY0.08 ElseIfRadioButton3.Checked True Then NX 30 DY 0.1 End If P SUM 1 DYDT DF / NX 12 Text
19、Box2.Text FormatP quot.quot End Sub Sy3.5Private Sub Button1_ClickByVal sender As System.Object ByVal eAs System.EventArgs Handles Button1.Click Dim a b c x1 x2 p1 p2 aValTextBox1.Text b ValTextBox2.Text c ValTextBox3.Textp1 b b - 4a c p2 Math.Sqrtb b - 4 a c If a 0 Then x1 -b / c x2x2.ToStringquotq
20、uot TextBox4.TextFormatx1 quot.quot x2.ToStringFormatx2 quot.quot Else If p1 gt 0 Then x1 -b p2 / 2 a x2 -b - p2 / 2 aTextBox4.Text Formatx1 quot.quot textbox5.Text Formatx2quot.quot ElseIf p1 lt 0 Then x1 x1.ToStringquotquot x2x2.ToStringquotquot Else p1 0 x1 -b / 2 a x2 -b / 2 a TextBox4.TextForma
21、tx1 quot.quot textbox5.Text Formatx2 quot.quot End If End IfEnd Sub Private SubButton2_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button2.Click End End Sub 实验四Sy4.1 Private Sub Form1_LoadByVal sender As System.ObjectByVal e As System.EventArgs Handles MyBase.Load Dim i jLa
22、bel1.TextAlign ContentAlignment.TopCenter For i 1 To 5Label1.Text amp quot quot For j 1 To 14 - 3 i - 1 Label1.Text ampquot quot Next Label1.Text amp quot quot amp vbNewLineNext Label1.Text amp quot quot amp vbNewLine 第六行 For i 1 To5 Labell.Text amp quot quot For j 1 To 2 3 i-1 Label1.Text amp quot
23、quot Next Label1.Text amp quot quotamp vbNewLine Next End Sub Sy4.2 Private SubButton1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim dis As Double i AsInteger For i 1 To 3600 dis 1 / i Next TextBox1.Focus TextBox1.TextFormatdis quot. 米 quot End Sub Private S
24、ub Button2_ClickByValsender As System.Object ByVal e As System.EventArgs HandlesButton2.Click Dim dis As Double 0 i As Double 1 t Do While dis lt 20dis 1 / i i 1 Loop t i / 3600 24 TextBox2.Focus TextBox2.Text Formattquot. 天 quot TextBox2.Text Stri amp quot 秒 quot End Sub Sy4.3Private Sub Button1_Cl
25、ickByVal sender As System.Object ByVal eAs System.EventArgs Handles Button1.Click Dim lv f bj Dim qx AsInteger i As Integer je As Single bj ValTextBox1.Text lvValTextBox2.Text/ 100 qx NumericUpDown1.Value Label4.Text quot年 quot amp Space10 amp quot 账户金额 quot amp vbNewLine Fori 1 To qx f Math.Pow1 lv
26、 i je bj f Label4.Text amp Stri amp Space10amp Strje amp vbNewLine Next End Sub Sy4.4 Private SubButton1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim x1 x2 x i As Integer x11 : x2 1 t x1 x2 For i 3 To 12 x x1 x2 x1 x2 x2 x t x Label1.TextFormatx quot 对兔子 qu
27、ot Next End Sub Sy4 思考 Private SubButton1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim dkqx As Integer dklAs Integer i As Integer myyh As Single Dim ylv qcjg dj nlv qcjgValTextBox1.Text dj ValTextBox2.Text nlv ValTextBox3.Textylv nlv /12 100 Label4.Text quo
28、tMonthsquot amp Space10 ampquotMonthlyquot amp Space1 amp quotPaymentsquot ampvbNewLine For i 2 To 5 dkqx i 12 dkl qcjg - dj myyh Pmtylv dkqx -dklLabel4.Text amp Strdkqx amp Space13 amp quotquot amp Space1amp Strmyyh amp vbNewLine Next End Sub 实验五 5.2 输入整数 n显示出具有 n 行的杨辉三角形。一个具有 8 行的杨辉三角形运行结果如图 所示。图中
29、两种输出效果在程序中有什么微笑的效果 PublicClass Form1 Private Sub Button1_ClickByVal sender AsSystem.Object ByVal e As System.EventArgs Handles Button1.ClickDim A100 100 As Integer Dim i As Integer j As Integer k As Integer nAs Integer n ValTextBox1.Text Label1.Text quotquot 计算 For i 0 Ton - 1 Ai 0 1 Ai i 1 Next For
30、 j 2 To n - 1 For k 1 To j - 1 Aj j - k Aj - 1 j - k- 1 Aj - 1 j - k Next Next 输出 For i 0 To n - 1 Label1.Text ampSpace30 - 3 i For j 0 To i Label1.Text amp Ai j amp Space5 NextLabel1.Text amp vbNewLine Next End Sub 加 个 限 定 条 件 PrivateSub TextBox1_LostFocusByVal sender As Object ByVal e AsSystem.Eve
31、ntArgs Handles TextBox1.LostFocus If NotIsNumericTextBox1.Text Or ValTextBox1.Text gt 10 OrValTextBox1.Text lt 0 Then MsgBoxquot 请输入小于 10 的正整 数quot TextBox1.Text quotquot TextBox1.Focus End If End Sub EndClass 5.3 Public Class Form1 Dim word10 Dim i 0 j k Private SubButton1_ClickByVal sender As Syst
32、em.Object ByVal e AsSystem.EventArgs Handles Button1.Click If TextBox1.Text ltgtquotquot Then Label3.Text TextBox1.Text amp vbNewLine wordiTextBox1.Text TextBox1.Text quotquot TextBox1.Focus i 1Array.Sortword Array.Reverseword End If End Sub Private SubButton2_ClickByVal sender As System.Object ByVa
33、l e AsSystem.EventArgs Handles Button2.Click For i 0 To word.Length - 1Label4.Text wordi amp vbNewLine Next End Sub End Class 5.4Private Sub Button1_ClickByVal sender As System.Object ByVal eAs System.EventArgs Handles Button1.Click Dim lamp100 Dim i j n nValTextBox1.Text For i 1 To n lampi 0 Next F
34、or i 2 To n For j i To n Ifj Mod i 0 Then If lampj 1 Then lampj 0 Else lampj 1 End If End If NextNext 输出 For j 1 To n If lampj 1 Then Label1.Text quot 第 quot ampStrj amp quot 盏灯亮 quot amp vbNewLine End If Next End SubPrivate Sub TextBox1_LostFocusByVal sender As Object ByVal e AsSystem.EventArgs Handles TextBox1.LostFocus If NotIsNumericTextBox1.Text Or ValTextBox1.Text lt 0 ThenMsgBoxquot 请 输 入 正 整 数 quot TextBox1.Text quotquotTextBox1.Focus End If End Sub 实验五思考 Public Class Form1Private Sub Button1_ClickByVal sender As System.Object ByVal eAs System.EventArgs
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年产00万吨钢铁生产线建设合同
- 2024正式版车辆转让合同标准范本
- 土建承包合同范本2024年
- 2024幼儿园合作合同范文
- 上海买房合同书
- 2024个人店铺出租合同范本
- 2024华硕电脑经销商订货单合同大客户
- 商铺合作经营协议
- 2024临时工合同协议书版临时工合同范本
- 2024新媒体主播合同
- 投标项目进度计划
- 中医脑病科缺血性中风(脑梗死恢复期)中医诊疗方案临床疗效分析总结
- 部编版语文二年级上册《语文园地三我喜欢的玩具》(教案)
- 软件开发项目验收方案
- 岗位整合整治与人员优化配置实施细则
- 康复治疗技术的职业规划课件
- 蜜雪冰城营销案例分析总结
- 交换机CPU使用率过高的原因分析及探讨
- 易制毒化学品安全管理岗位责任分工制度
- 住宿服务免责声明
- 2023年医疗机构消毒技术规范医疗机构消毒技术规范
评论
0/150
提交评论