一个很不错的清空页面所有文本框内容的函数(也可随意改成页面其他控件类型)

Private Sub SetTextBoxValue(ByVal Page As Control, ByVal TextBoxValue As String)
    
For Each ctl As Control In Page.Controls
            
If TypeOf ctl Is TextBox Then
                
CType(ctl, TextBox).Text = TextBoxValue
            
Else
                
If ctl.Controls.Count > 0 Then
                    SetTextBoxValue(ctl, TextBoxValue)
                
End If
            
End If
        
Next
End Sub
该函数功能见标题,
调用例子:SetTextBoxValue(Me.Page,"想置换的string")
如果想置换页面所有的Label,只要把
If TypeOf ct1 Is TextBox Then中的TextBox 改成Label就行了,很不错的函数,供参考。
posted on 2006-04-25 14:33  Carlwave-陆飞(Fei.Lu)  阅读(1529)  评论(1编辑  收藏  举报