You are only checking one of the boxes and you are checking to see if it is equal to a space. A blank text box will not be detected. The other boxes are not checked and therefore leave holes in your code.
I would not use Variant types here at all rather a string variable as we are looking for the text property.
I also would not pass the textbox to the function but the content of the text box instead.
If I were to use a function for this I would simply pass the text from the control and the default value and then return the proper value.
Code:
TextBox1.Text=GetVaild(TextBox1.Text,"1")
The line above would be used for each textbox
The function called would be something like
Code:
Function GetValid(DataString as string, DefaultValue as string) as String
If Trim(DataString)="" then
GetVaild=DefaultValue
Else
GetValid=DataString
End If
Of course I would most likely use a textbox array and just loop through them before processing.
As for attaching a value to a text box that will not be visible you can use the tag property but you still have to write code to place it in the text property or use tag instead at the time of processing.
In the case of a control array it is pretty simple. Lets say there are 10 text boxes all of which have the tag property set to the required default value and need to be checked.
Code:
Dim X as integer
For x = 0 to 9
If Trim(text1(x).text)="" then Text1(x).text=Text1(x).Tag
Next