vb 请看下面的代码

来源:百度知道 编辑:UC知道 时间:2024/06/15 19:21:25
模板代码
Public Function baoliu()
n = 14
For i = 0 To n

form3.Text1(i).Text = Round(Val(form3.Text1(i).Text), 3)

Next i
End Function
现在只能在form3中用
我想在不同的form中调用怎么改代码
Private Sub Command1_Click()
Text1(0) = lh / 2 - lh * lh * lh / (240 * r * r)
Text1(1) = lh * lh / (24 * r) - lh * lh * lh * lh / (2384 * r * r * r)
Text1(2) = 90 * lh / (r * 3.1425926)
Text1(3) = (r + Val(Text1(1))) * Tan(a / 2) + Text1(0)
Text1(4) = 3.1415926 * a * r / 180 + lh
Text1(5) = Text1(4) - 2 * lh
Text1(6) = (r + Val(Text1(1))) / Cos(a / 2) - r
Text1(7) = 2 * Val(Text1(3)) - Val(Text1(4))
Text1(8) = lh - lh * lh * lh / (40 * r * r)
Text1(9) = lh * lh / (6 * r) - lh * lh * lh * lh / (336 * r * r * r)
Text1(10) = z - Val(Text1(3))
Text1(11) = Val(Text1(10)) + lh
Text1(12) = Val(Text1(11)) + Val(Text1(5))
Text1(13) = Val(Text1(12)) - Val(Text

Public Function baoliu( f as Form)
n = 14
For i = 0 To n

f.Text1(i).Text = Round(Val(f.Text1(i).Text), 3)

Next i
End Function

不过,你的 Form 中一定要有 Text1(i) 控件哟!

form3 改成 me

Public Function baoliu()
n = 14
For i = 0 To n
Text1(i).Text = Round(Val(Text1(i).Text), 3)
Next i
End Function

在每个窗体调用就可以了

把form后那个数字设个参数变量。