Private Function makeTriangle(ByVal a As Double, ByVal b As Double, ByVal c As Double, ByRef TriangelType As Short) As Boolean
'可以从小到大排列三条边,使得a<=b<=c
'TriangelType表示三角形的类型0=等腰;1=等边;2=等腰直角;3=直角
Dim IsTriangle As Boolean = False 'IsTriangel判断是否是三角形
Dim IsRangle As Boolean = False '该变量用来判断是否是直角
If a + b >c Then IsTriangle = True
If IsTriangle Then
If a = b Then '等腰三角形
TriangelType = 0
If b = c Then TriangelType = 1 '等边三角形
End If
If a * a + b * b = c * c Then IsRangle = True
End If
If IsRangle Then
If TriangelType = 0 Then
TriangelType = 2 '等腰直角三角形
Else
TriangelType = 3 '直角三角形
End If
End If
Return IsTriangle
End Function
随机产生10个50-200的整数求其中最大值VB程序,需要采用的程序结构是:顺序结构、选择结构和循环结构都是需要的。
Private Sub Command1_Click()
Print "产生的50个随机整数是:"
Randomize
For i = 1 To 50
x = Int(Rnd * 151) + 50
Print x
If x >Max Then Max = x
If i Mod 10 = 0 Then Print
Next i
Print: Print "最大数="Max
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)