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
该函数功能见标题,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就行了,很不错的函数,供参考。