VB上机练习题_第1页
VB上机练习题_第2页
VB上机练习题_第3页
VB上机练习题_第4页
VB上机练习题_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Text2Text11.新建工程,界面如下图,将窗体名称改为f1,标题属性为“我的第一个工程”, Text2允许多行,三个命令按钮名称分别为C1、C2、C3,单击C1按钮将Text1的字体改为黑体,Text2的字体改为隶书。 单击C2按钮将Text1的文字颜色改为红色,Text2的背景颜色改为蓝色。单击C3按钮结束程序运行。22Private Sub Command1_Click() Text1.Font = 黑体End SubPrivate Sub Command2_Click() Text1.ForeColor = vbRed Text2.ForeColor = vbBlueEnd Sub

2、Private Sub Command3_Click() EndEnd Sub2.新建工程,界面如上图,运行时,鼠标在“改变窗体颜色”按钮上按下时使窗体背景色变为红色,鼠标抬起时使窗体背景色变为绿色。鼠标在窗体空白地方按下时使Text1的内容为“在窗体上按下了鼠标”,鼠标抬起时使Text1的内容为“在窗体上抬起了鼠标”。Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Form1.BackColor = vbRed End SubPrivate Sub Co

3、mmand1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Form1.BackColor = vbGreenEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Text1.Text = 在窗体上按下了鼠标End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Sing

4、le, Y As Single) Text1.Text = 在窗体上抬起了鼠标End Sub3.新建工程,界面如下图,运行时,在文本框Text1中输入内容的同时,在文本框Text2、Text3中显示相同的内容,但字体不同(字体自定)。Private Sub Command1_Click() Text1.Text = Text2.Text = Text3.Text = End SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Text1_Change() Text2.Text = Text1.Text Text3.Text = Text1.

5、TextEnd Sub注:“字体不同”可以在属性那调“Font” 4. 设计一个窗体,如上图所示。当单击某个命令按钮时,对文本框中的文字完成相应的设置。其中,每单击一次“增大”或“缩小”按钮将使文本框中的文字增大或缩小5磅,“粗体”按钮将使文本框中的文字加粗,“斜体”按钮将使文本框中的文字倾斜,“下划线”按钮将使文本框中的文字加下划线,“删除线”按钮将使文本框中的文字加删除线。Private Sub Command1_Click() Text1.FontSize = Text1.FontSize + 5End SubPrivate Sub Command2_Click() Text1.Font

6、Size = Text1.FontSize - 5End SubPrivate Sub Command3_Click() Text1.FontBold = TrueEnd SubPrivate Sub Command4_Click()Text1.FontItalic = TrueEnd SubPrivate Sub Command5_Click() Text1.FontUnderline = TrueEnd SubPrivate Sub Command6_Click() Text1.FontStrikethru = True End Sub5. 设计一个窗体,如下图所示。程序中将定义成符号常量

7、(用Const ),运行时,输入底面半径r和圆柱高h,然后单击“计算”命令按钮,在相应文本框中显示计算结果。运算结果为只读。Private Sub Command1_Click() Const pi = 3.14 h = Val(Text1) r = Val(Text2) Text3.Text = pi * r 2 Text4.Text = 2 * pi * r * h Text5.Text = pi * r 2 * hEnd Sub 6. 设计界面如上图所示。单击“出题”按钮,产生任意两个【1,100】之间的随机整数于Text1、 Text2中,单击“计算”按钮,求两个数的和。运算结果为只读

8、。Private Sub Command1_Click() Text1.Text = Int(100 * Rnd + 1) Text2.Text = Int(100 * Rnd + 1)End SubPrivate Sub Command2_Click() a = Val(Text1.Text) b = Val(Text1.Text) Text3.Text = a + bEnd Sub7设计一个数字钟表程序,界面如图所示。运行时单击窗体,显示当前的年月日星期及时间。Private Sub Form_Click() Label2.Caption = Year(Now) Label4.Captio

9、n = Month(Now) Label6.Caption = Day(Now) Label9.Caption = Weekday(Now) Label11.Caption = TimeEnd Sub 8设计一个数学函数程序,界面如图所示。程序运行时,在文本框中输入任意数值,单击相应按钮标签中显示结果。文本框始终处于选中状态。Private Sub Command1_Click() Label3.Caption = Abs(Val(Text1)Text1.SetFocus Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text)End SubPr

10、ivate Sub Command2_Click() Label3.Caption = Sqr(Val(Text1)Text1.SetFocus Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text)End SubPrivate Sub Command3_Click() Label3.Caption = Fix(Val(Text1)Text1.SetFocus Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text)End SubPrivate Sub Command4_Click() Label

11、3.Caption = Int(Val(Text1)Text1.SetFocus Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text)End SubPrivate Sub Command5_Click()Label3.Caption = Sgn(Val(Text1)Text1.SetFocus Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text)End Sub9设计一工程,在文本框中输入一整数,单击“判断”按钮,判断能否同时被3、5、7整除,若能用MsgBox函数显示“能同时被3、5、7整除

12、”,否则显示“不能整除”。 Private Sub Command1_Click() a = Val(Text1) If a Mod 3 = 0 And a Mod 5 = 0 And a Mod 7 = 0 Then MsgBox 能同时被3、5、7整除 Else MsgBox 不能整除 End IfEnd Sub10设计一个计算购书价钱的程序,界面如下图所示。为了提高运行速度,设置Tab键序,使得输入完单价后,焦点定位到输入数量文本框中。单击“计算总价”或用访问键,算出总价。总价文本框要求为只读属性。完成相应功能。 Private Sub Command1_Click() a = Val(

13、Text1) b = Val(Text2) Text3.Text = a * bEnd SubPrivate Sub Command2_Click() EndEnd Sub 11设计一工程,界面如上图所示。程序运行,单击“计算”,求出对应角度的三角函数的绝对值于文本框Text2中,同时要求选中文本框Text1内容,以便继续输入。 Private Sub Command1_Click() a = Val(Text1) b = a * 3.14 / 180 c = Abs(Sin(b) d = Abs(Cos(b) Text2.Text = Text2.Text & a & Space(10) &

14、 Format(c, 0.000) _ & Space(10) & Format(d, 0.000) & vbCrLf Text1.SetFocus Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text)End Sub12设计一个程序,用户界面如下图所示。程序运行后,单击“计算”,求出应付款额;单击“清除”, 清除所有文本框内容。 Private Sub Command1_Click() a = Val(Text1) b = Val(Text2) c = Val(Text3) Text4.Text = a * b * cEnd SubPriva

15、te Sub Command2_Click() Text1.Text = Text2.Text = Text3.Text = Text4.Text = End Sub13输入一个学生的学号和考试成绩,然后按如图格式在图片框中输出学号、考试成绩及评语,评语:90100优秀;8089良好;7079中等;6069及格;059不及格。Private Sub Command1_Click() a = Val(Text2) Select Case a Case 90 To 100 h = 优秀 Case 80 To 89 h = 良好 Case 70 To 79 h = 中等 Case 60 To 69

16、h = 及格 Case 0 To 59 h = 不及格 End Select Picture1.Print Picture1.Print 学号: & Text1.Text Picture1.Print Picture1.Print 分数: & a & Space(3) & hEnd Sub14设计一个窗体Forml,界面如上图所示。编写适当的事件过程,程序运行后在第一个文本框中输入圆的半径,单击“计算”按钮,分别在第二个和第三个文本框中显示圆的面积和周长。Private Sub Command1_Click() a = Val(Text1) Text2.Text = a 2 * 3.14 Te

17、xt3.Text = 2 * a * 3.14End Sub15设计一个程序,用户界面如下图所示。程序运行后,单击Command1按钮,求出最大、最小数。Private Sub Command1_Click() a = Val(Text1):b = Val(Text2):c = Val(Text3)If a b Then t = a: a = b: b = t If a c Then t = a: a = c: c = t If b c Then t = b: b = c: c = t Text4.Text = a Text5.Text = cEnd Sub 16界面如下图所示。编写适当的事件

18、过程,程序运行后在三个文本框中分别输入三角形的边长值,单击“判断并计算”按钮,判断它们是否能组成三角形,若能组成三角形在Text4中显示三角形的面积 ,否则在Text4中显示“FALSE”。Private Sub Command1_Click() a = Val(Text1):b = Val(Text2):c = Val(Text3)If a + b c Or a + c b Or b + c c Or Abs(a - c) b Or Abs(b - c) a Then Text4.Text = FALSE Else h = (a + b + c) / 2 s = Sqr(h * (h - a

19、) * (h - b) * (h - c) Text4.Text = Format(s, 0.00)End IfEnd Sub 17设计一个程序运行界面如下图所示,将输入的三个不同数,按从小到大的顺序排列。Private Sub Command1_Click()a = Val(Text1):b = Val(Text2):c = Val(Text3) If a b Then t = a: a = b: b = t If a c Then t = a: a = c: c = t If b 100000End SubPrivate Sub Command2_Click() s = 0 For i =

20、 1 To 20 n = 1 For k = 1 To i n = n * k Next k s = s + n Next i Label2.Caption = s End Sub19在窗体上画两个文本框输入a和n的值(a和n均为一位数字),单击命令按钮输出Sn=a+aa+aaa+aaaa+aaa(最后一项n个a,例如3+33+333+3333)的值于标签中。Private Sub Command1_Click() a = Text1.text n = Val(Text2) Sn = 0 For i = 1 To n b = String(i, a) Sn = Sn + Val(b) Next

21、 i Label1.Caption = SnEnd Sub20单击命令按钮将3到200之间的所有奇数显示在列表框中。Private Sub Command1_Click() For i = 3 To 200 Step 2 List1.AddItem i Next iEnd Sub21在窗体上画一文本框用于输入n值,画两个命令按钮分别求下述表达式的值S1=S2=1357(2n-1)并将S1、S2的结果输出到图片框。Private Sub Command1_Click() n = Val(Text1) s = 0 For i = 1 To n s = s + (-1) (i + 1) / (2 *

22、 i - 1) Next i S2 = 1 For i = 1 To n S2 = S2 * (2 * n - 1) Next i Picture1.Print 4 * s Picture1.Print S2End Sub22在文本框T1中打印100999之间的所有水仙花数。(该数为各位数字的立方和。例如:153=1 3+5 3+3 3 )Private Sub Command1_Click() For i = 100 To 999 a = Fix(i / 100) b = Fix(i / 10) - a * 10 c = i - Fix(i / 10) * 10 If a 3 + b 3 +

23、 c 3 = i Then T1.Text = T1.Text & i & vbCrLf Next iEnd Sub 23有一数列,它的头2个数为0、 1,以后的每个数都是其前2个数之和。编程在文本框T1中输出所有这些数列,直到第30个数或最后一项等于1000为止,同时在另一文本框中输出它们的和。Private Sub Command1_Click() a = 0: b = 1: s = 0 Text1.Text = a & vbCrLf & b & vbCrLf For i = 1 To 14 s = s + a + b a = a + b b = a + b Text1.Text = Te

24、xt1.Text & a & vbCrLf & b & vbCrLf Next i Text2.Text = sEnd Sub24设计如下图所示界面,单击时输出相应结果,2N之间素数在列表框中输出,要求判断素数用过程实现。Function h(a As Integer) As Boolean Dim m As Integer, s As Boolean m = 0 For i = 2 To (a - 1) If a Mod i = 0 Then m = m + 1 Next i If m = 0 Then s = True Else s = False h = s End FunctionPr

25、ivate Sub Command1_Click()Dim a As Integera = Val(Text1)If h(a) = False Then Text2.Text = 不是素数 Else Text2.Text = 是素数End IfEnd SubPrivate Sub Command2_Click()Dim i As Integera = Val(Text1)For i = 2 To a If h(i) = True Then List1.AddItem i Next iEnd Sub 25界面如上图,单击各按钮时输入行数,按此行数在窗体上显示不同的图形(参考教材练习6-15)。P

26、rivate Sub Command1_Click()Clsa = Val(InputBox(请输入行数)For i = 1 To a Print Tab(i); String(a, *)Next iEnd SubPrivate Sub Command2_Click()Clsa = Val(InputBox(请输入行数)For i = 1 To a Print Tab(a - i + 1); String(2 * i - 1, *) Next iEnd SubPrivate Sub Command3_Click()Clsa = Val(InputBox(请输入行数)For i = a To 1

27、 Step -1 Print Tab(a - i + 1); String(2 * i - 1, *) Next iEnd SubPrivate Sub Command4_Click()Clsa = Val(InputBox(请输入行数)For i = a To 1 Step -1 Print Tab(a - i + 1); String(2 * i - 1, *); _Space(3); String(2 * (a - i) + 1, *) Next iEnd Sub26设计如下图所示界面,单击时输出N!和1!+2!+N!结果,要求N!用过程实现。Function h(n As Intege

28、r) As IntegerDim s As Integer s = 1 For i = 1 To n s = s * iNext i h = sEnd FunctionPrivate Sub Command1_Click()Dim n As Integern = Val(Text1)Text2.Text = h(n)End SubPrivate Sub Command2_Click()Dim n As Integerm = Val(Text1)s = 0For n = 1 To m s = s + h(n)Next nText3.Text = sEnd Sub 27 编写一个程序,输出一个5*

29、5的矩阵,该矩阵主、负对角线上元素均为1,其余元素均为2,执行结果如上图所示。Option Base 1Dim A(5, 5) As IntegerPrivate Sub Form_Click()For i = 1 To 5 For j = 1 To 5 A(i, j) = 2 If i = j Then A(i, j) = 1 If i + j = 6 Then A(i, j) = 1 Next j, i For i = 1 To 5 CurrentY = i * 300 For j = 1 To 5 CurrentX = j * 300 Print A(i, j); Next j, iEn

30、d Sub28界面如下图所示。分别在Textl和Text2中输入两个自然数x、y,用展转相除的方法求自然数x,y的最大公约数和最小公倍数。在窗体上显示结果。Dim a As Integer, b As Integer, x As Integer, y As Integer,r as Integer Private Sub Command1_Click()x = Val(Text1)y = Val(Text2)a = x: b = yr = x Mod yDo While r 0 x = y y = r r = x Mod y Loop Label3.Caption = yEnd SubPriv

31、ate Sub Command2_Click()Label4.Caption = a * b / yEnd SubText1Text2Label3Label429仿照25题画四个命令按钮,单击各按钮在图片框上显示如下不同的数据图形。Private Sub Command1_Click() For i = 1 To 6 For j = i To 1 Step -1 Print j; Next jPrintNext iEnd SubPrivate Sub Command2_Click()For i = 6 To 1 Step -1Print Space(18 - 3 * i); For j = 1

32、 To i Print j; Next j Print Next iEnd SubPrivate Sub Command3_Click()For i = 1 To 6Print Space(18 - 3 * i); For j = i To 1 Step -1 Print 7 - j; Next j Print Next iEnd SubPrivate Sub Command4_Click()For i = 6 To 1 Step -1 For j = i To 1 Step -1 Print j; Next jPrintNext iEnd Sub30设计一个窗体Forml,编写适当的事件过程

33、。控制Text1中背景色和字体格式。(字体默认为宋体,内容为“欢迎学习VB”)程序运行界面如图所示。Private Sub Check1_Click()Text1.FontBold = TrueEnd SubPrivate Sub Check2_Click()Text1.FontItalic = TrueEnd SubPrivate Sub Check3_Click()Text1.FontUnderline = TrueEnd SubPrivate Sub Option1_Click()Text1.BackColor = vbRedEnd SubPrivate Sub Option2_Clic

34、k()Text1.BackColor = vbYellowEnd SubPrivate Sub Option3_Click()Text1.BackColor = vbBlueEnd Sub 31利用两个列表框控件,设计选项移动窗体如上图。编写适当的事件过程实现功能要求。Private Sub Command1_Click()If List1.ListCount = 0 Then MsgBox 列表中没有可选的列, , 注意 Exit SubIf List1.ListIndex = 0 ThenFor i = 0 To List1.ListCount 1 End IfEnd SubPrivate

35、 Sub Command2_Click()For i = 0 To List1.ListCount - 1 List1.Selected(0) = True List2.AddItem List1.Text List1.RemoveItem 0Next iEnd SubPrivate Sub Command4_Click()For i = 0 To List2.ListCount - 1 List2.Selected(0) = True List1.AddItem List2.Text List2.RemoveItem 0Next iEnd Sub32设计界面如下图所示,运行时,当移动滚动条时

36、,在标签中能正确显示摄氏、华氏温度值(C=5(F-32)/9) Private Sub Form_Load()VScroll1.Min = 100VScroll1.Max = 0End SubPrivate Sub VScroll1_Change()Label2.Caption = VScroll1.ValueLabel1.Caption = Format(VScroll1.Value * 9 / 5 + 32, #.0)End Sub 33设计上面界面,按“开始”按钮使标签在窗体上从左向右移动,当遇到窗体的右侧后,改成从右向左移动,按“停止”按钮停止标签移动。Dim a As Integer

37、Private Sub Command1_Click()Timer1.Enabled = TrueEnd SubPrivate Sub Command2_Click()Timer1.Enabled = FalseEnd SubPrivate Sub Timer1_Timer()End Sub34编写一个程序,实现在标签中自动依次显示“祝你”,“考试”,“成功”。Dim a As IntegerPrivate Sub Timer1_Timer()a = a + 1b = a Mod 3If b = 1 Then Label1.Caption = 祝你If b = 2 Then Label1.Ca

38、ption = 考试If b = 0 Then Label1.Caption = 成功End Sub35窗体上有一个名为L1的列表框,通过属性向列表框添加3个项目,分别是“123、456、789”。当启动后,每次双击列表框中任何一项,则总在最后添加一项,该项是所有项之和。界面如下图。Private Sub L1_DblClick()Dim b As Double, s As Doublea = Val(L1.ListCount)s = 0For i = 0 To ab = Val(L1.List(i) s = s + bNext iL1.AddItem sEnd Sub 36设计如上界面,编写

39、适当的事件过程。 程序运行后,每过1秒钟文本框的背景色能够由红到绿,绿到蓝,再由蓝到红循环变化。Dim a As IntegerPrivate Sub Timer1_Timer()a = a + 1b = a Mod 3If b = 1 Then Text1.BackColor = vbRedIf b = 2 Then Text1.BackColor = vbGreenIf b = 0 Then Text1.BackColor = vbBlueEnd Sub37单击第一个按钮,生成20个0,100之间的随机整数,显示于文本框1中,单击第二个按钮,求这20个数中的最大数和最小数,显示于文本框2中

40、。 Option Base 1Dim a(20) As IntegerPrivate Sub Command1_Click()Text1.Text = For i = 1 To 20 a(i) = Int(99 * Rnd - 0) Text1.Text = Text1.Text & a(i) & vbCrLf Next i For i = 1 To 19 For j = i + 1 To 20 If a(i) a(j) Then t = a(i) a(i) = a(j) a(j) = t End If Next j, i Text2.Text = a(1) & Space(3) & a(20

41、)End Sub38编写程序,单击第一个按钮,用随机函数产生4行5列的两位整数并输出到图片框1中。单击第二个按钮,实现将第1行和第3行数据交换或第2列和第4列数据交换,输出到图片框2中。Dim A(1 To 4, 1 To 5) As Integer, B(1 To 4, 1 To 5) As IntegerPrivate Sub Command1_Click()For i = 1 To 4 s1 = For j = 1 To 5 A(i, j) = Int(91 * Rnd + 10) s1 = s1 & Space(2) & A(i, j) Next jPicture1.Print s1

42、& vbCrLf Next iEnd SubPrivate Sub Command2_Click()For i = 1 To 4 s1 = For j = 1 To 5 If i Mod 2 0 Then c = 4 - i B(i, j) = A(c, j) s1 = s1 & Space(2) & B(i, j) Else B(i, j) = A(i, j) s1 = s1 & Space(2) & B(i, j) End If Next jPicture2.Print s1 & vbCrLf Next iEnd Sub39利用Function 计算N!,求组合数。在文本框1中输入n,文本

43、框2中输入m,单击命令按钮,在文本框3中显示组合结果。Function A(h As Integer) As IntegerDim s As Integer, i As Integers = 1For i = 1 To h s = s * iNext iA = sEnd FunctionPrivate Sub Command1_Click()Dim m As Integer, n As Integer, p As Integer, k As Doublen = Val(Text1): m = Val(Text2): p = m - nx = A(m): y = A(n): z = A(p)k

44、= x / (y * z)Text3.Text = kEnd Sub40生成两个010之间的随机整数矩阵,分别放入两个列表框,求两个矩阵之和放入第三个列表框。如下图所示。Private Sub Form_Load()For i = 1 To 5 s1 = For j = 1 To 5 a(i, j) = Int(Rnd * 11) s1 = s1 & Format(a(i, j), !) Next j List1.AddItem s1 & vbCrLfNext iFor i = 1 To 5 s1 = For j = 1 To 5 b(i, j) = Int(Rnd * 11) s1 = s1

45、 & Format(b(i, j), !) Next j List2.AddItem s1 & vbCrLfNext iEnd SubPrivate Sub Command1_Click()For i = 1 To 5 s1 = For j = 1 To 5 c(i, j) = a(i, j) + b(i, j) s1 = s1 & Format(c(i, j), !) Next j List3.AddItem s1 & vbCrLfNext iEnd SubPrivate Sub Command2_Click()EndEnd Sub 41生成10个两位数的随机整数, 放入A数组, 单击显示按

46、钮全部显示在文本框1中,单击排序按钮由小到大排序,显示在文本框2中。(如上图)Option Base 1Dim A(10) As IntegerPrivate Sub Command1_Click()For i = 1 To 10 A(i) = Int(91 * Rnd + 10) Text1.Text = Text1.Text & A(i) & Space(1) Next iEnd SubPrivate Sub Command2_Click()For i = 1 To 9 For j = i + 1 To 10 If A(i) A(j) Then t = A(i) A(i) = A(j) A

47、(j) = t End If Next j, i For i = 1 To 10 Text2.Text = Text2.Text & A(i) & Space(1) Next iEnd Sub42如下图,单击显示按钮,将20个随机两位整数,输出在LIST1中;单击排序按钮,将使用子过程降序排序的结果输出在LIST2中。Option Base 1Dim A(10) As IntegerPrivate Sub Command1_Click()For i = 1 To 10 A(i) = Int(91 * Rnd + 10) List1.AddItem A(i) Next iEnd SubPriva

48、te Sub Command2_Click()For i = 1 To 9 For j = i + 1 To 10 If A(i) A(j) Then t = A(i) A(i) = A(j) A(j) = t End If Next j, i For i = 1 To 10 List2.AddItem A(i) Next iEnd Sub 43编写适当的事件过程,在窗体上输出相应行数的杨辉三角形。点击窗体弹出InputBox对话框,在对话框中输入行数,打印出如上图所示形态的杨辉三角形。Dim A() As IntegerPrivate Sub Form_Click()Dim m As Int

49、eger, n As Integer m = Val(InputBox(请输入行数) n = m ReDim A(m, n) For i = 0 To m - 1 A(i, i) = 1 A(i, 0) = 1 Next i Print Tab(3 * m - 1); 1For i = 2 To n - 1 s = For j = 1 To i - 1 A(i, j) = A(i - 1, j) + A(i - 1, j - 1) s = s & Space(5) & A(i, j)Next jPrint Tab(3 * (m - i); A(i, 0) & s & Space(5) & A(

50、i, i)Next iEnd Sub44编写程序,实现矩阵转置,即将一个nm的矩阵(均由随机函数产生,并且是两位整数)的行和列互换。单击显示按钮将原矩阵放在图片框1,单击转置按钮将转置后的矩阵输出在图片框2。Option Base 1Dim a(4, 5) As Integer, b(5, 4) As IntegerPrivate Sub Command1_Click()For i = 1 To 4s = For j = 1 To 5 a(i, j) = Int(91 * Rnd + 10) s = s & Space(2) & a(i, j) Next jPicture1.Print sNe

51、xt iEnd SubPrivate Sub Command2_Click()For i = 1 To 5s = For j = 1 To 4 b(i, j) = a(j, i) s = s & Space(2) & b(i, j) Next jPicture2.Print sNext iEnd Sub 45编写函数过程计算1+2+3+。+n,运行时输入m,n,p的值,单击“Y=”输出结果(保留三位小数)。如上图所示。Function A(h As Integer) As IntegerDim s As Integer, i As Integers = 0For i = 1 To h s = s + iNext iA = sEnd FunctionPrivate Sub Command1_Click()Dim m As Integer, n As Integer, p As Integer, k As Doublem = Val(Text1): n = Val(Text2): p = Val(Text3)x = A(m): y = A(n): z = A(p)k = (x + y) / zText4.Text = kEnd Sub46利用控件数组Text1、Text2将Text1中随机产生的数,交换到Text

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论