×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBA Multipage

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

RE: VBA Multipage

(OP)
Sorry cowski,

Looked at the website you suggested but could not see how it would help.

best regards,

athomas236

RE: VBA Multipage

What exactly are you trying to do?  Especially your step 3.  What do you want to trigger this action?  A button?  When any text box is updated?  If you want to ignore certain boxes just don't include them in your code.  You'll probably want to do separate routines for each page of your 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

The link I posted would help you with your question 1 & 2. When you show your form simply loop through the textboxes and set them all to "". When you select a page an event is fired, on that event loop through the textboxes on the opposite page and set them to "".

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

(OP)
Gentlemen,

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources