【VB开源代码栏目提醒】:网学会员在VB开源代码频道为大家收集整理了“vb程序设计全部答案(最新) - 编程语言“提供大家参考,希望对大家有所帮助!
1 . 给定年份和月份,判断该年是否是闰年。
并根据给出的月份判断是什么季节、该月有 多少天。
(闰年的条件是:年份能被 4 整除但不能被 100 整除或能被 400 整除)Private Sub Button1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim Year Month Day As Integer Dim a b As String Year ValTextBox1.Text Month Val TextBox2.Text If Label1.Text quotquot Or Label2.Text quotquot Then 若用户没有填写年份或月份,退出事件过程 TextBox1.Focus End If If Year Mod 4 0 And Year Mod 100 ltgt 0 Or Year Mod 400 0 Then 判断是否为闰年 b quot是润年quot Else b quot不是闰年quot End If Select Case Month 判断月份所在的季节 Case 3 To 5 a quot春季quot Case 6 To 8 a quot夏季quot Case 9 To 11 a quot秋季quot Case 1 2 12 a quot冬季quot End Select Select Case Month 判断某月中包含的天数 Case 2 If b quot是闰年,quot Then Day 29 Else Day 28 End If Case 4 6 9 11 Day 30 Case Else 上面的条件都不成立,即1,3,5,7,8,10,12月 Day 31 End Select Label3.Text Year amp quot年quot amp b amp Month amp quot月有quot amp Day amp quot天quot amp quot,quotquot在quot amp a End SubEnd Class2.编写程序,输入学生的姓名、学号和成绩(高数、英语和专业课),判断该学生能获得几等奖学金,并输出结果。
获奖条件是:一等奖学金要求所有成绩在 95 分以上;二等奖学金要求所有成绩在 90 分以上;三等奖学金要求所有成绩在 88 分以上。
Private Sub Button1_ClickByVal sender As System.Object ByVal e As System.EventArgs Handles Button1.Click Dim a b c As Integer Dim name num As String name TextBox1.Text num TextBox2.Text a ValTextBox3.Text b ValTextBox4.Text c ValTextBox5.Text If a gt 90 And a lt 100 And b gt 90 And b lt 100 And c gt 90 And c lt 100 Then Label7.Text name amp quot同学quot amp vbCrLf amp quot学号quot amp num amp vbCrLf amp quot获得quot amp quot一等奖quot ElseIf 90 lt a And a lt 96 And 90 lt b And b lt 96 And 90 lt c And c lt 96 Then Label7.Text name amp quot同学quot amp vbCrLf amp quot学号quot amp num amp vbCrLf amp quot获得quot amp quot二等奖quotElseIf 88 lt a And a lt 91 And 88 lt b And b lt 91 And 88 lt c And c lt 91 Then Label7.Text name amp quot同学quot amp vbCrLf amp quot学号quot amp num amp vbCrLf amp quot获得quot amp quot三等奖 Else Label7.Text quot无奖项quot End If End Sub Private Sub Button2_ClickByVal sender As Object ByVal e As System.EventArgsHandles Button2.Click TextBox1.Text quotquot TextBox2.Text quotquot TextBox3.Text quotquot TextBox4.Text quotquot TextBox5.Text quotquot End SubPrivate Sub Button3_ClickByVal sender As Object ByVal e As System.EventArgs Handles Button3.Click End End SubEnd Class3.已知: 当任意输入 x 值时求 fx的值。
请编制程序完成。
Private Sub Button1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim x y As Integer x ValTextBox1.Text y ValTextBox2.Text If x ltgt -3 And x lt 0 Then y x 2 x - 6 Else If x gt 0 And x lt 10 And x ltgt 2 And x ltgt 3 Then y x 2 - 5 x 6 Else y x 2 - x - 1 End If TextBox2.Text y End SubEnd Class4.编写一个
程序输入某人的身高(cm)和体重(kg),按下式确定其体重是否为标准、过 胖或过瘦:(1)标准体重身高-110;(2)超过标准体重 5kg 为过胖;(3)低于标准体重 5kg 为瘦。
Private Sub Button1_ClickByVal sender As System.Object ByVal e AsSystem.EventArgs Handles Button1.Click Dim a b c As Integer a ValTextBox1.Text b ValTextBox2.Text c a - 100 If b a Then Label3.Text quot标准体重quot Else If b gt c 5 Then Label3.Text quot胖quot Else If b lt c - 5 Then Label3.Text quot痩quot End If End SubEnd Class5. 征兵的条件是:男性(sex)年龄(age)在 1820 之间,身高(size)在 1.65 米以上;或者女性(sex)年龄(age)在 1618 之间,身高(size)在 1.60 米以上。
用三个文本框控件分别输入性别、年龄、身高信息,根据这些信息判断是否符合征兵条件,用标签控件输出结果。
Private Sub Button1_ClickByVal sender As System