ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reset TextBox values on userform (https://www.excelbanter.com/excel-programming/378551-re-reset-textbox-values-userform.html)

Chip Pearson

Reset TextBox values on userform
 
VBA doesn't support control arrays, so the syntax TextBox1(i) is all wrong.

Try the following

Dim Ctrl As MSForms.Control
For Each Ctrl In frmOrderForm.Controls
If TypeOf Ctrl Is MSForms.Textbox Then
Ctrl.Text = vbNullString
End If
Next Ctrl


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Trevor Williams" wrote in
message ...
I'm trying to reset all textboxes on a form to a zero string before the
form
initializes, but without any success - what am I doing wrong?

For i = 1 To 15
frmOrderForm.TextBox1(i).Text = ""
Next i

Thanks - Trevor





All times are GMT +1. The time now is 01:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com