菜鸟我又来问vb啦,急!!!

来源:百度知道 编辑:UC知道 时间:2024/05/23 20:16:26
用辗转相除法求最大公约数(帮我看看哪错了,就是运行不了啊)
Private Sub Command1_Click()
If (Val(Text1.Text) > Val(Text2.Text)) Then
m = Val(Text1.Text)
n = Val(Text2.Text)
Else: m = Val(Text2.Text)
n = Val(Text1.Text)
End If
Do While n <> 0
r = m Mod n
If (r = 0) Then
Text3.Text = n
Else
m = n
n = r
End If
Loop
End Sub

Private Sub Form_Load()

End Sub

Private Sub Command1_Click()
If (Val(Text1.Text) > Val(Text2.Text)) Then
m = Val(Text1.Text)
n = Val(Text2.Text)
Else: m = Val(Text2.Text)
n = Val(Text1.Text)
End If
Do While n <> 0
r = m Mod n
∶¨¨¨¨¨¨¨¨∶
∶If (r = 0) Then ∶
∶Text3.Text = n ∶
∶Else ∶(不要)
¨¨¨¨¨¨¨¨¨¨
m = n
n = r
'End If
Loop
commaon=m'最大公约数
End Sub

语法都不记得了。不好意思,好久没接触编程了

这样
Private Sub Command1_Click()
If (Val(Text1) > Val(Text2)) Then
m = Val(Text1)
n = Val(Text2)
Else
m = Val(Text2)
n = Val(Text1)
End If
Do While n <> 0
r = m Mod n
If r = 0 Then Text3 = n
m = n
n = r
Loop
End Sub

好像是死循环,没有仔细看。