




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
此文档收集于网络,如有侵权,请联系网站删除实验一 dim a20 as intergers10 as interger private sub button1_click.handles button1.click dim ij textbox1.textquotquot for i1 to 20 aiintrnd101 textbox1.textampaiampspace6-lenai jai10 select casej case 0to 5 s5s51 case 9to 10 s9s91 case 6to 8 sjsj1 end select next i end sub private sub button2_click.handles button2.click textbox2.textquot0-59:quotamps5ampvbcrlf textbox2.textquot60-69:quotamps6ampvbcrlf textbox2.textquot70-79:quotamps7ampvbcrlf textbox2.textquot80-89:quotamps8ampvbcrlf textbox2.textquot90-100:quotamps9ampvbcrlf buton1 dim lamp100 dim ijn nvaltextbox1.text for i1to n lampi0 next for i2 to n for ji to n if j mod 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 not isnumerictextbox1.textor valtextbox1.textlt0 then msgboxquot请输入正整数quot textbox1.textquotquot textbox1.text.focus end if end sub 实验二 SY2.1 Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click Dim f c c ValTextBox2.Text f 9 / 5 c 32 TextBox1.Text Formatf quot.quot End Sub Sy2.2 Public Class Form1 Dim RMB As Integer Dim Change Dol As Double Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click TextBox1.Text quotquot TextBox2.Text quotquot TextBox3.Text quotquot End Sub Private Sub Button4_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button4.Click End End Sub Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click RMB ValTextBox1.Text Change ValTextBox2.Text Dol RMB / Change TextBox3.Text FormatDol quot.quot End Sub Private Sub Button3_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button3.Click Dol ValTextBox3.Text Change ValTextBox2.Text RMB Dol Change TextBox1.Text FormatRMB quotquot End Sub End Class Sy2.3 Public Class Form1 Dim PI 3.1415926 Dim Square Circle R Private Sub TextBox1_TextChangedByVal sender As System.Object ByVal e As System.EventArgs Handles TextBox1.TextChanged If IsNumericTextBox1.Text False Or TextBox1.Text quotquot Then MsgBoxquot请输入数字quot ElseIf TextBox1.Text lt 0 Then MsgBoxquot请输入正数quot End If End Sub Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click R ValTextBox1.Text Square PI R R TextBox2.Text FormatSquare quot.quot End Sub Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click R ValTextBox1.Text Circle 2 PI R TextBox3.Text FormatCircle quot.quot End Sub End Class Sy2.4 Private Sub Form1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles MyBase.Click If TextBox1.Text ltgt quothelloquot Then MsgBoxquot用户名不对quot ElseIf IsNumericTextBox2.Text False Then TextBox2.Text quotquot TextBox2.Focus ElseIf ValTextBox2.Text lt 0 Then MsgBoxquot请输入正数quot ElseIf TextBox2.Text ltgt quot123456quot Then MsgBoxquot密码错误quot Else MsgBoxquot登录成功quot End If End Sub 实验三 Sy3.2 Public Class Form1 Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click TextBox1.Text quotquot TextBox2.Text quotquot TextBox3.Text quotquot TextBox4.Text quotquot TextBox1.Focus End Sub Private Sub Button3_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button3.Click End End Sub Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim x y z m x ValTextBox1.Text y ValTextBox2.Text z ValTextBox3.Text If x gt y And y gt z Then m x x z z m ElseIf x gt y And y lt z And x lt z Then m x 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 y m 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 ElseIf x 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 Then End If TextBox4.Text x amp quotltquot amp y amp quotltquot amp z End Sub End Class Sy3.3 Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click TextBox1.Text quotquot TextBox2.Text quotquot TextBox3.Text quotquot TextBox4.Text quotquot End Sub Private Sub Button3_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button3.Click End End Sub Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim m1 m2 m3 avg Dim rank As String m1 ValTextBox1.Text m2 ValTextBox2.Text m3 ValTextBox3.Text avg m1 m2 m3 / 3 If avg lt 80 Then TextBox4.Text quot无奖quot ElseIf avg gt 80 And avg lt 85 Then TextBox4.Text quot三等奖quot ElseIf avg gt 85 And avg lt 90 And m1 gt 80 And m2 gt 80 And m3 gt 80 Then TextBox4.Text quot二等奖quot ElseIf avg gt 90 Then TextBox4.Text quot一等奖quot ElseIf m1 100 And m2 100 And m3 gt 85 Then TextBox4.Text quot一等奖quot ElseIf m1 100 And m2 gt 85 And m3 100 Then TextBox4.Text quot一等奖quot ElseIf m1 gt 85 And m2 100 And m3 100 Then TextBox4.Text quot一等奖quot End If End Sub Sy3.4 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim DF NX DY DT SUM P SUM ValTextBox1.Text If CheckBox1.Checked Then DF 0.95 Else DF 1 End If If RadioButton4.Checked True Then DT 1 ElseIf RadioButton5.Checked True Then DT 0.9 End If If RadioButton1.Checked True Then NX 10 DY 0.05 ElseIf RadioButton2.Checked True Then NX 20 DY 0.08 ElseIf RadioButton3.Checked True Then NX 30 DY 0.1 End If P SUM 1 DY DT DF / NX 12 TextBox2.Text FormatP quot.quot End Sub Sy3.5 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim a b c x1 x2 p1 p2 a ValTextBox1.Text b ValTextBox2.Text c ValTextBox3.Text p1 b b - 4 a c p2 Math.Sqrtb b - 4 a c If a 0 Then x1 -b / c x2 x2.ToStringquotquot TextBox4.Text Formatx1 quot.quot x2.ToString Formatx2 quot.quot Else If p1 gt 0 Then x1 -b p2 / 2 a x2 -b - p2 / 2 a TextBox4.Text Formatx1 quot.quot textbox5.Text Formatx2 quot.quot ElseIf p1 lt 0 Then x1 x1.ToStringquotquot x2 x2.ToStringquotquot Else p1 0 x1 -b / 2 a x2 -b / 2 a TextBox4.Text Formatx1 quot.quot textbox5.Text Formatx2 quot.quot End If End If End Sub Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click End End Sub 实验四 Sy4.1 Private Sub Form1_LoadByVal sender As System.Object ByVal e As System.EventArgs Handles MyBase.Load Dim i j Label1.TextAlign ContentAlignment.TopCenter For i 1 To 5 Label1.Text amp quotquot For j 1 To 14 - 3 i - 1 Label1.Text amp quotquot Next Label1.Text amp quotquot amp vbNewLine Next Label1.Text amp quotquot amp vbNewLine 第六行 For i 1 To 5 Label1.Text amp quotquot For j 1 To 2 3 i - 1 Label1.Text amp quotquot Next Label1.Text amp quotquot amp vbNewLine Next End Sub Sy4.2 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim dis As Double i As Integer For i 1 To 3600 dis 1 / i Next TextBox1.Focus TextBox1.Text Formatdis quot. 米quot End Sub Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click Dim dis As Double 0 i As Double 1 t Do While dis lt 20 dis 1 / i i 1 Loop t i / 3600 24 TextBox2.Focus TextBox2.Text Formatt quot. 天quot TextBox2.Text Stri amp quot秒quot End Sub Sy4.3 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim lv f bj Dim qx As Integer i As Integer je As Single bj ValTextBox1.Text lv ValTextBox2.Text / 100 qx NumericUpDown1.Value Label4.Text quot 年quot amp Space10 amp quot账户金额quot amp vbNewLine For i 1 To qx f Math.Pow1 lv i je bj f Label4.Text amp Stri amp Space10 amp Strje amp vbNewLine Next End Sub Sy4.4 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim x1 x2 x i As Integer x1 1 : x2 1 t x1 x2 For i 3 To 12 x x1 x2 x1 x2 x2 x t x Label1.Text Formatx quot对兔子quot Next End Sub Sy4思考 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim dkqx As Integer dkl As Integer i As Integer myyh As Single Dim ylv qcjg dj nlv qcjg ValTextBox1.Text dj ValTextBox2.Text nlv ValTextBox3.Text ylv nlv / 12 100 Label4.Text quotMonthsquot amp Space10 amp quotMonthlyquot amp Space1 amp quotPaymentsquot amp vbNewLine For i 2 To 5 dkqx i 12 dkl qcjg - dj myyh Pmtylv dkqx -dkl Label4.Text amp Strdkqx amp Space13 amp quotquot amp Space1 amp Strmyyh amp vbNewLine Next End Sub 实验五 5.2输入整数n显示出具有n行的杨辉三角形。一个具有8行的杨辉三角形运行结果如图所示。图中两种输出效果在程序中有什么微笑的效果 Public Class Form1 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim A100 100 As Integer Dim i As Integer j As Integer k As Integer n As Integer n ValTextBox1.Text Label1.Text quotquot 计算 For i 0 To n - 1 Ai 0 1 Ai i 1 Next For 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 amp Space30 - 3 i For j 0 To i Label1.Text amp Ai j amp Space5 Next Label1.Text amp vbNewLine Next End Sub 加个限定条件 Private Sub TextBox1_LostFocusByVal sender As Object ByVal e As System.EventArgs Handles TextBox1.LostFocus If Not IsNumericTextBox1.Text Or ValTextBox1.Text gt 10 Or ValTextBox1.Text lt 0 Then MsgBoxquot请输入小于10的正整数quot TextBox1.Text quotquot TextBox1.Focus End If End Sub End Class 5.3 Public Class Form1 Dim word10 Dim i 0 j k Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click If TextBox1.Text ltgt quotquot Then Label3.Text TextBox1.Text amp vbNewLine wordi TextBox1.Text TextBox1.Text quotquot TextBox1.Focus i 1 Array.Sortword Array.Reverseword End If End Sub Private Sub Button2_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button2.Click For i 0 To word.Length - 1 Label4.Text wordi amp vbNewLine Next End Sub End Class 5.4 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim lamp100 Dim i j n n ValTextBox1.Text For i 1 To n lampi 0 Next For i 2 To n For j i To n If j Mod i 0 Then If lampj 1 Then lampj 0 Else lampj 1 End If End If Next Next 输出 For j 1 To n If lampj 1 Then Label1.Text quot第quot amp Strj amp quot盏灯亮quot amp vbNewLine End If Next End Sub Private Sub TextBox1_LostFocusByVal sender As Object ByVal e As System.EventArgs Handles TextBox1.LostFocus If Not IsNumericTextBox1.Text Or ValTextBox1.Text lt 0 Then MsgBoxquot请输入正整数quot TextBox1.Text quotquot TextBox1.Focus End If End Sub 实验五思考 Public Class Form1 Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.E
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度关键基础设施网络安全监测服务合同
- 2025年城市住宅置换协议:商品房产权互换及使用权转让合同
- 2025年新型材料研发中心工程承包及质量保障合同
- 2025年文化园区共建协议:影视产业与旅游产业融合发展计划
- 2025年新能源电池研发与市场推广合作协议
- 2025年BIM技术在建筑工程中的应用与后期维护服务协议
- 对外承包项目借款合同
- 2025年环境监测智能化技术趋势与数据质量控制策略分析报告
- 物业管理委托合同书
- 2025年电动汽车电池热管理技术新材料研发与创新驱动研究报告
- 艺康servsafe培训课件
- TDT1067-2021不动产登记数据整合建库技术规范
- 加气站投诉处理管理制度
- 2025-2030年再生铝行业市场现状供需分析及投资评估规划分析研究报告
- Unit 3 Same or Different?Section A 课件 人教版英语八年级上册
- 智能仓储物流管理平台的设计与开发
- 2025上海戏剧学院辅导员考试试题及答案
- 中国热射病诊断与治疗指南(2025版)
- 眼科患者的体位管理
- 物流中级考试试题及答案
- 小学一年级100以内加减法练习题3000道
评论
0/150
提交评论