1、重庆医科大学 Visual Basic 上机实验上机试验一1. 中英文切换程序。鼠标单击“中文”命令按钮后,在标签中显示中文“谢谢光临!”;如果单击“英文“命令按钮后,在标签中显示英文“Thanks for your attendance!”,如图所示。窗体文件名为 SY1-2,工程文件名也为 SY1-2。重庆医科大学 Visual Basic 上机实验上机试验二1. 在窗口中添加一个标签,设置 BorderStyle 属性为有边框,编写程序代码实现:单击窗体后,标签上显示如图所示的信息,标签文字字体设置为隶书,文字大小 20,加粗,倾斜,下画线。完成后保存文件,窗体文件名为 SY2-1,工程
2、文件名也为 SY2-1。2. 在窗体上,按下鼠标右键拖动,在窗体的标题栏中显示鼠标指针的坐标位置。完成后保存文件,窗体文件名为 SY2-2,工程文件名也为 SY2-2。Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 2 ThenForm1.Caption = X a(i, j);Next jNext i重庆医科大学 Visual Basic 上机实验End Sub倒计时系统Dim t%Private Sub Command1_Click()t
3、 = 60 * Val(Text1)Timer1.Enabled = TrueEnd SubPrivate Sub Form_Load()Timer1.Enabled = FalseTimer1.Interval = 1000End SubPrivate Sub Timer1_Timer()Dim s%, m%t = t - 1m = t 60s = t Mod 60Label1 = m & “分 “ & s & “秒 “If t = 0 Then重庆医科大学 Visual Basic 上机实验Timer1.Enabled = FalseMsgBox “时间到! “End IfEnd SubD
4、im R As Integer, G As Integer, B As IntegerPrivate Sub Form_Load()VScroll1.Min = 0VScroll1.Max = 255VScroll2.Min = 0VScroll2.Max = 255VScroll3.Min = 0VScroll3.Max = 255VScroll1.LargeChange = 20VScroll1.SmallChange = 5VScroll2.LargeChange = 20VScroll2.SmallChange = 5VScroll3.LargeChange = 20重庆医科大学 Vi
5、sual Basic 上机实验VScroll3.SmallChange = 5End SubPrivate Sub VScroll1_Change()Picture1.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)End SubPrivate Sub VScroll2_Change()Picture1.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)End SubPrivate Sub VScroll3_Change()Picture1.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)End SubDim ti As Single, x As Integer, j As Single重庆医科大学 Visual Basic 上机实验Private Sub Form_Click()j = 1: ti = 0For x = 1 To 11111 Step 1j = j * xti = 1 / j + tiIf (1 / j) (10 -7) Then Exit ForNext xti = ti + 1Print tiEnd Sub