求VB一个算法

来源:百度知道 编辑:UC知道 时间:2024/06/25 12:01:51
text1 输入100 text2 等于1
(不足100按1计)也就是text1输入99 text2也是输出1
如果text1输入101 text2就等于2. 按每100个数为1,不足100按1计,
请问这个怎么实现?

Private Sub Command1_Click()
If Val(Text1.Text) Mod 100 = 0 Then
Text2.Text = Val(Text1.Text) / 100
Else
Text2.Text = Int(Val(Text1.Text) / 100) + 1
End If
End Sub

Private Sub Text1_Change()
a = Val(Text1)
If a = 0 Then
Text2 = 0
Else
Text2 = Int((a-1) / 100) + 1
End If
End Sub

Private Sub Text1_Change()
Text2.Text = (Val(Text1.Text) - 1) \ 100 + 1
End Sub

Private Sub Text1_Change()
Text2.Text = Int(Val(Text1.Text) / 100) + 1
End Sub