苏小云的VB
苏小云班长吧
全部回复
仅看楼主
level 4
实验29-1
Public Class Form1
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Dim var1 As Integer, var2 As String
var1 = 12345
var2 = InputBox("输入Var2=", "输入对话框")
MsgBox(var2 & Chr(13) + Chr(10) & "var1=" & Str(var1))
'MsgBox(var2 & vbCrLf & "var1=" & Str(var1))
End Sub
End Class
2015年01月15日 10点01分 1
level 4
实验29-2
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
Dim b As Single
Dim c As Integer
Dim d As Date
Dim e1 As String
Dim f As Boolean
Dim g As String
Dim h As Double
Dim i As Single
Dim j(4, 3) As Integer
a = 325
b = 546.0
c = 5383149
d =
#12/31/2003#

e1 = "ABCDEF"
f = False
g = "123456"
h = 32.4
i = 1256.3
j(0, 0) = 456
MsgBox(a & vbCrLf & b & vbCrLf & c & vbCrLf & d & vbCrLf & e1 & vbCrLf & f & vbCrLf & g & vbCrLf & h & vbCrLf & i & vbCrLf & j(0, 0))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim x21, x22, x23, x24 As Single
Dim x25, x27, x28 As Boolean
Dim x26 As String
x21 = Sqrt(3 ^ 2 / (2 * 4))
x22 = +Abs(0.123 - 3)
x23 = -Sin(30)
x24 = Exp(6) + Log(2.135)
x25 = 89 & 12 <> 8912
x26 = "AB" + Str(32.56) + "CD"
'x27 = Mid("student", 5) = "ent" And (5 > 2)
x27 = Microsoft.VisualBasic.Right("student", 3) = "ent" And (5 > 2)
x28 = Not (6 > 2) Or (7 < 9)
MsgBox(x21 & vbCrLf & x22 & vbCrLf & x23 & vbCrLf & x24 & vbCrLf & x25 & vbCrLf & x26 & vbCrLf & x27 & vbCrLf & x28)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim y As Integer
y = Int(Rnd() * 100)
MsgBox(y)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim y As String
Dim y1 As Integer
y = "VB程序设计语言"
y1 = Len(y)
MsgBox(y & "长度为" & y1)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim y As Integer
y = InStr("abc student", "stu")
MsgBox(y)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim y As String
y = Trim(" Visual C ++ ")
MsgBox("去除左边空格" & y & "去除右边空格")
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim y As String
Dim y1 As Integer
y = "VB程序设计语言"
y1 = Len(y) * 2
MsgBox(y & " 字节数为" & y1)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim y, y1 As String
y = "我去资料室查资料"
y1 = StrReverse(y)
MsgBox(y1)
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim y, y1 As String
y = "我去资料室查资料"
y1 = Mid(y, 3, 3)
MsgBox(y1)
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Dim y, y1 As String
y = "我去资料室查资料"
y1 = Mid(y, 7, 2)
'y1 = Microsoft.VisualBasic.Right(y, 2)
MsgBox(y1)
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
Dim y, y1 As String
y = "Thisisabook"
y1 = Mid(y, 1, 4) & Space(1) & Mid(y, 5, 2) & Space(1) & Mid(y, 7, 1) & Space(1) & Mid(y, 8)
MsgBox(y1)
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
Dim y As Integer
y = Asc("Z")
MsgBox(y)
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
Dim y As Date
Dim y1, y2, y3 As Integer
y = "2013-1-1"
y1 = DateDiff(DateInterval.Month, y, Today())
y2 = DateDiff(DateInterval.WeekOfYear, y, Today())
y3 = DateDiff(DateInterval.Day, y, Today())
MsgBox(y1 & "个月" & y2 & "个星期" & y3 & "天")
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
Dim y As String
Dim a As Integer
Dim y1 As Integer
y = "42897"
y1 = Val(y)
a = MsgBox(y1, vbOKCancel)
If vbOK = a Then
MsgBox(a)
End If
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
Dim y As Single
y = 3287.153
MsgBox(Format(y, "000.00"))
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
Dim z1, z2, z3, z4 As Single
Dim z5, z6, z7 As String
Dim z8 As Date
z1 = 45.632
z2 = 8246.25
z3 = 123.8
z4 = 45627
z5 = "student"
z6 = "permanence"
z7 = "teachers"
z8 =
#4/5/2004#

MsgBox(Format(z1, "00000.00") & " " & Format(z2, "00000.00") & " " & Format(z3, "00000.00") & " " & Format(z4, "00000.00") & vbCrLf & Format(z5, "{0,-12}") & " " & Format(z6, "{0,-12}") & " " & Format(z7, "{0,-12}") & " " & Format(z8, "d"))
End Sub
End Class
2015年01月15日 10点01分 2
level 4
实验30-1 (求平方根;xy函数计算;重力加速度)
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String, b As String, c As String
Dim x1 As Single, x2 As Single
a = InputBox("输入A", "输入数据Y", , 500, 500)
b = InputBox("输入B", "输入数据Y", , 500, 500)
c = InputBox("输入C", "输入数据Y", , 500, 500)
x1 = -b + Math.Sqrt(b ^ 2 - 4 * a * c) / 2 / a
x2 = -b - Math.Sqrt(b ^ 2 - 4 * a * c) / 2 / a
MsgBox("x1=" & Format(x1, "###.##
#") & " x2=" & Format(x2, "#
##.###"))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim x As Integer
Dim y As Integer
Dim z As Single
x = 5
y = 9
z = (x ^ 3 + x * y + y ^ 3) / (2 * x * y)
MsgBox("(x ^ 3 + x * y + y ^ 3) / (2 * x * y)=" & z)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim x As Single
Dim y As Single
x = InputBox("输入x")
y = Math.Log(20) + Math.Abs(x - 16)
MsgBox("Math.Log(20) + Math.Abs(x - 16)=" & y)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim x As Single
Dim y As Single
x = InputBox("输入x")
y = 0.231 * x + 1.36
MsgBox("0.231 * x + 1.36=" & y)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Const g As Single = 9.81
Dim v As Single, o As Single, t As Single, s As Single
v = InputBox("输入初速度")
o = InputBox("输入角度")
t = 2 * v * Math.Sin(o * Math.PI / 180) / g
s = v * Math.Sin(2 * o * Math.PI / 180) / g
MsgBox("落地所需时间" & t & " 落地时运动的射程" & s)
End Sub
End Class
2015年01月15日 10点01分 3
level 4
实验30-2 (判断奇偶;判断大小;分段函数;IF...THEN...语句;IF...THEN...ELSE...ENDIF语句;IF...THEN...ELSEIF...ENDIF语句;SELECT CASE...END SELECT语句)
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer
x = Int(Rnd() * 100)
If x Mod 2 = 0 Then
MsgBox(x & "是偶数")
Else
MsgBox(x & "是奇数")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim a As Single, b As Single, c As Single, x As Single, y As Single
a = InputBox("请输入a")
b = InputBox("请输入b")
c = InputBox("请输入c")
If a > b Then
x = a
y = b
Else
x = b
y = a
End If
If c > a Then
x = c
Else
If c < b Then
y = c
End If
End If
MsgBox("最大数" & x & " 最小数" & y)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim t As Single, f As Single
t = InputBox("请输入t")
If t < 120 Then
f = 0.06 * t + 2
MsgBox("f = 0.06 * t + 2=" & f)
Else
f = 0.06 * t * 0.85
MsgBox("f = 0.06 * t * 0.85=" & f)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim x As Single
Dim y As String
x = InputBox("请输入成绩")
If x >= 90 Then
y = "A"
ElseIf x >= 80 Then
y = "B"
ElseIf x >= 70 Then
y = "C"
ElseIf x >= 60 Then
y = "D"
Else
y = "E"
End If
MsgBox("成绩" & x & "等级为" & y)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim x As Single, y As Single
x = InputBox("请输入x")
Select Case x
Case Is <= -1
y = x - 1
Case Is <= 2
y = 2 * x
Case Is <= 10
y = x * (x + 2)
Case Else
y = 0
End Select
MsgBox("y=" & y)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim a As String, b As String, c As String
Dim x1 As Single, x2 As Single, x As Single
a = InputBox("输入A", "输入数据Y", , 500, 500)
b = InputBox("输入B", "输入数据Y", , 500, 500)
c = InputBox("输入C", "输入数据Y", , 500, 500)
x = b ^ 2 - 4 * a * c
If x >= 0 Then
x1 = -b + Math.Sqrt(x) / 2 / a
x2 = -b - Math.Sqrt(x) / 2 / a
MsgBox("x1=" & Format(x1, "###.##
#") & " x2=" & Format(x2, "#
##.###"))
Else
x1 = Math.Sqrt(-x) / 2 / a
x2 = -Math.Sqrt(-x) / 2 / a
MsgBox("x1=" & -b / 2 / a & x1 & "i x2=" & -b / 2 / a & x2 & "i")
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim x As Single, y As Single
x = InputBox("请输入x")
If x <= -1 Then
y = x - 1
ElseIf x <= 2 Then
y = 2 * x
ElseIf x <= 10 Then
y = x * (x + 2)
End If
MsgBox("y=" & y)
End Sub
End Class
2015年01月15日 10点01分 4
level 4
实验33-1 汽油收费计算
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim t As Integer, f As Single, x As String
t = Val(TextBox1.Text)
f = 7.69 * t
x = Str$(f) + "元"
Label2.Text = x
TextBox1.Focus()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = ""
Label2.Text = ""
End Sub
End Class
2015年01月15日 10点01分 7
level 4
实验33-2 编制检测体重是否超标
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer
If TextBox1.Text = "" Then
TextBox1.Focus() '在文本框1输入身高
MsgBox("请输入身高")
Exit Sub
End If
If TextBox2.Text = "" Then
TextBox2.Focus() '在文本框2输入体重
MsgBox("请输入体重")
Exit Sub
End If
'选择性别
If RadioButton1.Checked = False And RadioButton2.Checked = False Then '此种情况不会发生
MsgBox("请选择被检测者性别")
Exit Sub
End If
If RadioButton1.Checked = True Then
x = Val(TextBox1.Text) - 100 '计算男性体重
ElseIf RadioButton2.Checked = True Then
x = Val(TextBox1.Text) - 105 '计算女性体重
End If
'判断体重是否超标,并显示
If Val(TextBox2.Text) > x Then
Label3.Text = "体重超标,请注意饮食与运动!"
Else
Label3.Text = "体重正常"
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'清除计算体重和超标提示
Label3.Text = "" : TextBox1.Text = "" : TextBox2.Text = ""
RadioButton1.Checked = False : RadioButton2.Checked = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End '结束工程运行
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Show()
TextBox1.Focus()
End Sub
End Class
2015年01月15日 10点01分 8
level 4
实验33-3 医生录入病人信息和病案信息
Public Class Form1
Dim x As Integer, varstring As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox3.Enabled = False
Button1.Enabled = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Regular)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Select Case True
Case CheckBox1.Checked = True And CheckBox2.Checked = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Bold)
Case CheckBox2.Checked = True And CheckBox1.Checked = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Italic)
Case CheckBox1.Checked And CheckBox2.Checked
TextBox3.Font = New Font("宋体", 10, FontStyle.Bold Or FontStyle.Italic)
Case CheckBox1.Checked = False And CheckBox2.Checked = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Regular)
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Enabled = True
TextBox3.Text = TextBox1.Text & TextBox2.Text
If RadioButton1.Checked = True Then
TextBox3.Text = TextBox3.Text & RadioButton1.Text
ElseIf RadioButton2.Checked = True Then
TextBox3.Text = TextBox3.Text & RadioButton2.Text
End If
End Sub
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
x = Len(TextBox1.Text)
If x <> 6 Then
Beep()
TextBox1.Text = ""
TextBox1.Focus()
TextBox3.Clear()
TextBox3.Text = "病历号为6位数字"
Else
TextBox3.Clear()
Button1.Enabled = True
End If
End Sub
End Class
2015年01月15日 10点01分 9
level 4
实验33-4 图书馆借书程序
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(ComboBox1.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ListBox1.SelectedIndex = -1 Then
MsgBox("请选择要删除的书!")
Exit Sub
End If
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim num As Integer
num = ListBox1.Items.Count
For i = 0 To num - 1
If ListBox1.Items(i) = "内科学" Or ListBox1.Items(i) = "外科学" Then
MsgBox("您已经借阅了一本期刊,不能再借阅期刊!")
Exit Sub
End If
Next i
If RadioButton1.Checked = True Then
ListBox1.Items.Add("内科学")
ElseIf RadioButton2.Checked = True Then
ListBox1.Items.Add("外科学")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
2015年01月15日 10点01分 10
level 4
实验33-5 门诊诊病开方
Public Class Form1
Dim Var As String, Hx As Integer, Vx As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Var$ = ComboBox1.Text + ComboBox2.Text + ComboBox3.Text + ComboBox4.Text
Select Case Var$
Case Is = "肿痛轻度38度干咳"
TextBox1.Text = "咽炎"
Case Is = "化脓中度39度早起咳"
TextBox1.Text = "扁桃体发炎"
Case Is = "化脓重度40度有痰"
TextBox1.Text = "肺炎"
Case Else
TextBox1.Text = "重选"
End Select
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
ListBox2.Items.Add(ListBox1.Text)
End Sub
Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
'首先判断列表框中的项是否大于0
If (ListBox2.Items.Count > 0) Then
'移出选择的项()
'ListBox2.Items.Remove(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
2015年01月15日 10点01分 11
level 4
实验33-思考题 图书馆借书 一次删除选中的多行项目
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(ComboBox1.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
While ListBox1.SelectedIndex > -1
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End While
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim num As Integer
num = ListBox1.Items.Count
For i = 0 To num - 1
If ListBox1.Items(i) = "内科学" Or ListBox1.Items(i) = "外科学" Then
MsgBox("您已经借阅了一本期刊,不能再借阅期刊!")
Exit Sub
End If
Next i
If RadioButton1.Checked = True Then
ListBox1.Items.Add("内科学")
ElseIf RadioButton2.Checked = True Then
ListBox1.Items.Add("外科学")
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'设置列表框多项选择
ListBox1.SelectionMode = SelectionMode.MultiSimple
End Sub
End Class
2015年01月15日 10点01分 12
level 4
实验34-3 宣传不要吸烟的广告
Public Class Form1
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
i = 0
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If i = 0 Then
PictureBox1.Image = PictureBox2.Image
i = 1
Else
PictureBox1.Image = PictureBox3.Image
i = 0
End If
If Label1.Left < 0 Then
Label1.Left = Me.Width
Else
Label1.Left = Label1.Left - 30
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
2015年01月15日 10点01分 15
level 4
实验34-4 小孩过马路 动画设计
Public Class Form1
Dim ts As Integer
Dim orst As Integer
Dim orsl As Integer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Timer1.Enabled = False
VScrollBar1.Minimum = 10
VScrollBar1.Maximum = 100
orst = PictureBox1.Top
orsl = PictureBox1.Left
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Top = orst
PictureBox1.Left = orsl
Timer1.Enabled = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Interval = VScrollBar1.Value
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If PictureBox1.Top < Me.Height Then
PictureBox1.Top = PictureBox1.Top + 10
Else
Timer1.Enabled = False
End If
End Sub
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
Timer1.Interval = VScrollBar1.Value
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
End Sub
End Class
2015年01月15日 10点01分 16
level 4
实验34-5 医学影像片子诊阅 图片查看
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Button4.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button1.Image = My.Resources.CRDFLE12
Button2.Image = My.Resources.EYE
Button3.Image = My.Resources.ARW09RT
Button4.Image = My.Resources.KEY06
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
PictureBox1.Image = My.Resources.R1
Button4.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.PictureBox1.Image = My.Resources.R1
Form2.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
PictureBox3.Image = PictureBox1.Image
PictureBox3.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim x As Integer
x = Val(InputBox("设置缩小比例系数x="))
PictureBox2.SizeMode = PictureBoxSizeMode.CenterImage
PictureBox2.Image = PictureBox1.Image
PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox3.Height = PictureBox1.Image.Height / x
PictureBox3.Width = PictureBox1.Image.Width / x
PictureBox3.Image = PictureBox1.Image
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
End Class
2015年01月15日 10点01分 17
level 4
实验36-1 菜单演示窗体,加载其他应用窗体(汽油收费和检测体重)
Public Class Form_menu
Private Sub Gas_fee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Gas_fee.Click
Form_gas.Show()
End Sub
Private Sub test_avoirdupois_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles test_avoirdupois.Click
Form_Test.Show()
End Sub
Private Sub Exit1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Exit1.Click
Me.Close()
End Sub
Private Sub Form_menu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
汽油收费应用窗体
Public Class Form_gas
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim t As Integer, f As Single, x As String
t = Val(TextBox1.Text)
f = 7.69 * t
x = Str$(f) + "元"
Label2.Text = x
TextBox1.Focus()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = ""
Label2.Text = ""
End Sub
End Class
体重检测应用窗体
Public Class Form_Test
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer
If TextBox1.Text = "" Then
TextBox1.Focus() '在文本框1输入身高
MsgBox("请输入身高")
Exit Sub
End If
If TextBox2.Text = "" Then
TextBox2.Focus() '在文本框2输入体重
MsgBox("请输入体重")
Exit Sub
End If
'选择性别
If RadioButton1.Checked = False And RadioButton2.Checked = False Then '此种情况不会发生
MsgBox("请选择被检测者性别")
Exit Sub
End If
If RadioButton1.Checked = True Then
x = Val(TextBox1.Text) - 100 '计算男性体重
ElseIf RadioButton2.Checked = True Then
x = Val(TextBox1.Text) - 105 '计算女性体重
End If
'判断体重是否超标,并显示
If Val(TextBox2.Text) > x Then
Label3.Text = "体重超标,请注意饮食与运动!"
Else
Label3.Text = "体重正常"
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'清除计算体重和超标提示
Label3.Text = "" : TextBox1.Text = "" : TextBox2.Text = ""
RadioButton1.Checked = False : RadioButton2.Checked = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End '结束工程运行
End Sub
Private Sub Form_Test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
2015年01月15日 10点01分 18
level 4
实验36-4 医院临床管理示范系统 (病历,开方,医学影像诊阅)
Public Class MenuDemo
Private Sub MainToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MainToolStripMenuItem.Click
'设置ToolStrip1控件的Visible属性
If MainToolStripMenuItem.Checked = True Then
ToolStrip1.Visible = True
Else
ToolStrip1.Visible = False
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub ToolStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ToolStrip1.ItemClicked
End Sub
Private Sub DiagnosisToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DiagnosisToolStripMenuItem.Click
Diagnosis.Show()
End Sub
Private Sub ImageCheckToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageCheckToolStripMenuItem.Click
Form1.Show()
End Sub
Private Sub PaCaseEnterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PaCaseEnterToolStripMenuItem.Click
BasicEnter.Show()
End Sub
Private Sub MenuDemo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
病历
Public Class BasicEnter
Dim x As Integer, varstring As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox3.Enabled = False
Button1.Enabled = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Regular)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Select Case True
Case CheckBox1.Checked = True And CheckBox2.Checked = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Bold)
Case CheckBox2.Checked = True And CheckBox1.Checked = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Italic)
Case CheckBox1.Checked And CheckBox2.Checked
TextBox3.Font = New Font("宋体", 10, FontStyle.Bold Or FontStyle.Italic)
Case CheckBox1.Checked = False And CheckBox2.Checked = False
TextBox3.Font = New Font("宋体", 10, FontStyle.Regular)
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Enabled = True
TextBox3.Text = TextBox1.Text & TextBox2.Text
If RadioButton1.Checked = True Then
TextBox3.Text = TextBox3.Text & RadioButton1.Text
ElseIf RadioButton2.Checked = True Then
TextBox3.Text = TextBox3.Text & RadioButton2.Text
End If
End Sub
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
x = Len(TextBox1.Text)
If x <> 6 Then
Beep()
TextBox1.Text = ""
TextBox1.Focus()
TextBox3.Clear()
TextBox3.Text = "病历号为6位数字"
Else
TextBox3.Clear()
Button1.Enabled = True
End If
End Sub
End Class
开方
Public Class Diagnosis
Dim Var As String, Hx As Integer, Vx As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Var$ = ComboBox1.Text + ComboBox2.Text + ComboBox3.Text + ComboBox4.Text
Select Case Var$
Case Is = "肿痛轻度38度干咳"
TextBox1.Text = "咽炎"
Case Is = "化脓中度39度早起咳"
TextBox1.Text = "扁桃体发炎"
Case Is = "化脓重度40度有痰"
TextBox1.Text = "肺炎"
Case Else
TextBox1.Text = "重选"
End Select
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
ListBox2.Items.Add(ListBox1.Text)
End Sub
Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
'首先判断列表框中的项是否大于0
If (ListBox2.Items.Count > 0) Then
'移出选择的项()
ListBox2.Items.Remove(ListBox2.SelectedItem)
End If
End Sub
Private Sub Diagnosis_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
医学影像诊阅
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Button4.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button1.Image = My.Resources.CRDFLE12
Button2.Image = My.Resources.EYE
Button3.Image = My.Resources.ARW09RT
Button4.Image = My.Resources.KEY06
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
PictureBox1.Image = My.Resources.R1
Button4.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.PictureBox1.Image = My.Resources.R1
Form2.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
PictureBox3.Image = PictureBox1.Image
PictureBox3.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim x As Integer
x = Val(InputBox("设置缩小比例系数x="))
PictureBox2.Image = PictureBox1.Image
PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox3.Height = PictureBox2.Image.Height / x
PictureBox3.Width = PictureBox2.Image.Width / x
PictureBox3.Image = PictureBox1.Image
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
2015年01月15日 10点01分 21
1