Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer
Dim x1 As Single, x2 As Single, x3 As Single, t As Single Dim Totald As Integer, v As Single, s As String
s = Text1.Text
k = 0: j = 1: Totald = 0
For i = 1 To Len(s)
If Mid(s, i, 1) = "," Then
v = Val(Mid(s, j, i - j)) '提取三角形边长,保存在变量v中
①
If k Mod 3 = 1 Then
x1 = v
ElseIf k Mod 3 = 2 Then x2 = v
If x1 < x2 Then t = x1: x1 = x2: x2 = t
Else
x3 = v
If x1 < x3 Then t = x1: x1 = x3: x3 = t
If ② Then Totald = Totald + 1
End If
End If
Next i
Label1.Caption = "一共构成" + Str(Totald) + " 个直角三角形"
End Sub
① ②