VB程序题(4).docx_第1页
VB程序题(4).docx_第2页
VB程序题(4).docx_第3页
VB程序题(4).docx_第4页
VB程序题(4).docx_第5页
全文预览已结束

下载本文档

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

文档简介

1在窗体Form1中实现函数MarkClass。mark参数为成绩,函数对成绩的评价。成绩评价方法为:90及以上优秀,80及以上良好,70及以上中等,60及以上及格,60以下不及格。Public Function MarkClass(mark As Long) As StringEnd FunctionPublic Function markclass(mark As Long) As StringDim s$If mark = 90 Thens = 优秀 ElseIf mark = 80 Thens = 良好 ElseIf mark = 70 Thens = 中等 ElseIf mark = 60 Thens = 及格 Else:s = 不及格End Ifmarkclass = sEnd Function2在窗体Form1中实现函数MySgn。当参数x0时,函数MySgn返回1;当参数x 0 Thenmysgn = 1ElseIf x = 0 Thenmysgn = 0Elsemysgn = -1End IfEnd Function3在窗体Form1中实现函数TriangleArea。a,b,c三个参数为三角形三条边,若三边能构成三角形,函数返回三角形面积;否则返回0。提示: 海伦公式为: , Public Function TriangleArea(a As Long, b As Long, c As Long) As DoubleEnd FunctionPublic Function trianglearea(a As Long, b As Long, c As Long) As DoubleDim s%, p%p = (a + b + c) / 2s = Sqr(p * (p - a) * (p - b) * (p - c)If a + b = c Or a + c = b Or b + c = a Thentrianglearea = 0Elsetrianglearea = sEnd IfEnd Function4在窗体Form1中实现函数TriangleClass。a,b,c三个参数为三角形三条边,函数返回三角形的形状。可能的三角形形状为以下4种:等边三角形,等腰三角形,一般三角形,不构成三角形。Public Function TriangleClass(a As Long, b As Long, c As Long) As StringEnd FunctionPublic Function triangleclass(a As Long, b As Long, c As Long) As StringDim s$If a + b = c Or b + c = a Or a + c b And a c Then max = aIf b a And b c Then max = bIf c b And c a Then max = cIf a b And a c Then min = aIf b a And b c Then min = bIf c b And c y Then Max = x Else Max = y End IfEnd Function7在窗体Form1中实现子程序Swap。Swap功能为:使第一个实参变量为较大值,第二个实参变量为较小值。Public Sub Swap(x As Long, y As Long)End SubSub swap(x As Long, y As Long) Dim t As Long If x 0: b3 = y Mod 400 = 0 leap = b1 And b2 Or b3 Select Case m Case 1, 3, 5, 7, 8, 10, 12 days = 31 Case 4, 6, 9, 11 days = 30 Case 2 If leap Then days = 29 Else days = 28 End If End SelectEnd Function9在窗体Form1中实现子程序MaxMin。参数中的a,b,c为三个数,通过max和min将找到的最大值和最小值以参数的形式返回。Public Sub MaxMin(a As Long, b As Long, c As Long, max as Long, min as Long)End SubSub MaxMin(a As Long, b As Long, c As Long, max As Long, min As Long) If a b And a c Then max = a If b a And b c Then max = b If c a And c b Then max = c If a b And a c Then min = a If b a And b c Then min = b If c a And c b Then min = cEnd Sub10在窗体Form1中实现函数Perfect。如果参数x为完全数,该函数返回True;否则返回False。(完全数:真因子(除自身以外的因子)之和为其本身)Public Function Perfect(x As Long) As BooleanEnd FunctionFunction perfect(x As Long) As BooleanDim i%, s%For

温馨提示

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

最新文档

评论

0/150

提交评论