主题:求助,程序中有几个text box,change的时候会相互修改应该怎么办
程序如下,想实现的功能很简单,一共八个窗口,想在任何一个窗口输入数值的时候其他窗口的数值会同时改变,但是这样会出现各个窗口相互修改的情况,最后出现"堆栈空间溢出"的问题,向大神们求救怎么修改这个程序,
PS,我完全是生手,只是想写个小程序方便平时使用,望轻喷
Private Sub Text1_Change()
Dim St As String
Dim E1!, E2!, w1!, w2!, F1!, F2!, T1!, T2!
St = Text1.Text
E1 = Val(St)
E2 = E1 * 1000
Text2.Text = E2
If E1 = 0 Then
Text3.Text = "infinity"
Text4.Text = "infinity"
Else
w1 = 6.626176 * 300 / 1.602 / E1
w2 = 6.626176 * 300 / 1.602 / E1 / 1000
Text3.Text = w1
Text4.Text = w2
End If
F1 = E1 / 4.135667516 * 1000 / 2.998 * 100
F2 = E1 / 4.135667516 * 1000
Text5.Text = F1
Text6.Text = F2
If F1 = 0 Then
Text7.Text = "infinity"
Text8.Text = "infinity"
Else
T1 = 1000 / F2
T2 = 1 / F2
Text7.Text = T1
Text8.Text = T2
End If
End Sub
Private Sub Text2_Change()
St = Text2.Text
E2 = Val(St)
E1 = E2 / 1000
Text1.Text = E1
If E1 = 0 Then
Text3.Text = "infinity"
Text4.Text = "infinity"
Else
w1 = 6.626176 * 300 / 1.602 / E1
w2 = 6.626176 * 300 / 1.602 / E1 / 1000
Text3.Text = w1
Text4.Text = w2
End If
F1 = E1 / 4.135667516 * 1000 / 2.998 * 100
F2 = E1 / 4.135667516 * 1000
Text5.Text = F1
Text6.Text = F2
If F1 = 0 Then
Text7.Text = "infinity"
Text8.Text = "infinity"
Else
T1 = 1000 / F2
T2 = 1 / F2
Text7.Text = T1
Text8.Text = T2
End If
End Sub
Private Sub Text3_Change()
Dim St As String
St = Text3.Text
w1 = Val(St)
w2 = w1 / 1000
Text4.Text = w2
If w1 = 0 Then
Text1.Text = "infinity"
Text2.Text = "infinity"
Else
E1 = 6.626176 * 300 / 1.602 / w1
E2 = 6.626176 * 300 / 1.602 / w1 * 1000
Text1.Text = E1
Text2.Text = E2
End If
If w1 = 0 Then
Text5.Text = "infinity"
Text6.Text = "infinity"
Else
F1 = E1 / 4.135667516 * 1000 / 2.998 * 100
F2 = E1 / 4.135667516 * 1000
Text5.Text = F1
Text6.Text = F2
End If
T1 = 1000 / F2
T2 = 1 / F2
Text7.Text = T1
Text8.Text = T2
End Sub
Private Sub Text4_Change()
St = Text4.Text
w2 = Val(St)
w1 = w2 * 1000
Text3.Text = w1
If w1 = 0 Then
Text1.Text = "infinity"
Text1.Text = "infinity"
Else
E1 = 6.626176 * 300 / 1.602 / w1
E2 = 6.626176 * 300 / 1.602 / w1 * 1000
Text1.Text = E1
Text2.Text = E2
End If
If w1 = 0 Then
Text5.Text = "infinity"
Text6.Text = "infinity"
Else
F1 = E1 / 4.135667516 * 1000 / 2.998 * 100
F2 = E1 / 4.135667516 * 1000
Text5.Text = F1
Text6.Text = F2
End If
T1 = 1000 / F2
T2 = 1 / F2
Text7.Text = T1
Text8.Text = T2
End Sub
Private Sub Text5_Change()
St = Text5.Text
F1 = Val(St)
F2 = F1 * 2.998 / 100
Text6.Text = F2
E1 = F1 * 4.135667516 / 1000 * 2.998 / 100
E2 = E1 * 1000
Text1.Text = E1
Text2.Text = E2
If E1 = 0 Then
Text3.Text = "infinity"
Text4.Text = "infinity"
Else
w1 = 6.626176 * 300 / 1.602 / E1
w2 = 6.626176 * 300 / 1.602 / E1 / 1000
Text3.Text = w1
Text4.Text = w2
End If
If F1 = 0 Then
Text7.Text = "infinity"
Text8.Text = "infinity"
Else
T1 = 1000 / F2
T2 = 1 / F2
Text7.Text = T1
Text8.Text = T2
End If
End Sub
Private Sub Text6_Change()
St = Text6.Text
F2 = Val(St)
F1 = F2 / 2.998 * 100
Text5.Text = F1
E1 = F1 * 4.135667516 / 1000 * 2.998 / 100
E2 = E1 * 1000
Text1.Text = E1
Text2.Text = E2
If E1 = 0 Then
Text3.Text = "infinity"
Text4.Text = "infinity"
Else
w1 = 6.626176 * 300 / 1.602 / E1
w2 = 6.626176 * 300 / 1.602 / E1 / 1000
Text3.Text = w1
Text4.Text = w2
End If
If F1 = 0 Then
Text7.Text = "infinity"
Text8.Text = "infinity"
Else
T1 = 1000 / F2
T2 = 1 / F2
Text7.Text = T1
Text8.Text = T2
End If
End Sub
Private Sub Text7_Change()
St = Text7.Text
T1 = Val(St)
T2 = T1 / 1000
Text8.Text = T2
If T1 = 0 Then
Text5.Text = "infinity"
Text6.Text = "infinity"
Else
F2 = 1000 / T1
F1 = F2 / 2.998 * 100
Text5.Text = F1
Text6.Text = F2
End If
If T1 = 0 Then
Text1.Text = "infinity"
Text2.Text = "infinity"
Else
E1 = F1 * 4.135667516 / 1000 * 2.998 / 100
E2 = E1 * 1000
Text1.Text = E1
Text2.Text = E2
End If
w1 = 6.626176 * 300 / 1.602 / E1
w2 = 6.626176 * 300 / 1.602 / E1 / 1000
Text3.Text = w1
Text4.Text = w2
End Sub
Private Sub Text8_Change()
St = Text8.Text
T2 = Val(St)
T1 = T2 * 1000
Text7.Text = T1
If T1 = 0 Then
Text5.Text = "infinity"
Text6.Text = "infinity"
Else
F2 = 1000 / T1
F1 = F2 / 2.998 * 100
Text5.Text = F1
Text6.Text = F2
End If
If T1 = 0 Then
Text1.Text = "infinity"
Text2.Text = "infinity"
Else
E1 = F1 * 4.135667516 / 1000 * 2.998 / 100
E2 = E1 * 1000
Text1.Text = E1
Text2.Text = E2
End If
w1 = 6.626176 * 300 / 1.602 / E1
w2 = 6.626176 * 300 / 1.602 / E1 / 1000
Text3.Text = w1
Text4.Text = w2
End Sub