VBA Multipage
VBA Multipage
(OP)
I am writing an application in which I am using a multipage that has two pages. One page is used to enter saturated steam conditions and one to enter superheated steam/subcooled water conditions. All data is entered via text boxes.
What I want to do is the following:
1. When I show the userform, I want to set all text box values on the multipage to empty.
2. When either page of the multipage is selected, set the text boxes on the non selected page to empty.
3. For the selected page, check that data has been entered and ignore the fact that the text boxes on the non selected page are empty.
Any advice/guidance will be appreciated.
athomas236
What I want to do is the following:
1. When I show the userform, I want to set all text box values on the multipage to empty.
2. When either page of the multipage is selected, set the text boxes on the non selected page to empty.
3. For the selected page, check that data has been entered and ignore the fact that the text boxes on the non selected page are empty.
Any advice/guidance will be appreciated.
athomas236





RE: VBA Multipage
http://www.ozgrid.com/VBA/control-loop.htm
To clear a textbox, set its .text property to "".
RE: VBA Multipage
Looked at the website you suggested but could not see how it would help.
best regards,
athomas236
RE: VBA Multipage
cowski's link is to code that will give you access to each control on your form without having to specify it by name. This will help you on step 1. You'll just have to check what type of control it is and, if it's a text box, set it's .text property to "". Check the msForms help for properies/methods of the Control object. There should be a .type property or something that will tell you if the control is a text box or not.
RE: VBA Multipage
You might want to rethink #2. Personally, as a user I would be pretty upset if all my input data was erased simply by switching pages. Maybe put a control button on each sheet to process the information on each sheet separately.
For #3, you don't have to 'actively ignore' any input. It is up to you to write code to validate and process the input. If you want to ignore certain input then you simply don't write code for it.
RE: VBA Multipage
1. This is the code I use for entering data through a textbox and to check if the box is empty and valid.
Private Sub CommandButton1_Click()
' This is standard code to accept input through text box
' Validate the input
If Not IsNumeric(TextBox4) Then
MsgBox "Invalid or missing saturated steam data."
Exit Sub
End If
' This is standard code for changing input from text box
' into a number
a = Val(TextBox4.Text)
MsgBox "Input = " & a
End Sub
2. On the first page of the multipage the input is either pressure or temperature so I can calculate the conditions on the saturated steam line and on the second page is pressure and temperature so I can calculate steam conditions off the saturation line. I just want the values on the unselected page to be blank.
Best regards,
athomas236