Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Recommended Posts

how do you make a form that you can tab thru the text boxes and have the values in the boxes be highlighted. I've written a VBA/VB Script function for Mastercam that starts with default values in the text boxes but the user can tab thru them and enter new data. Currently I highlight, with the mouse, the value in the box and overwrite it. Really want to be able to tab and then just type the new value.

 

How???

Link to comment
Share on other sites

In the VBA Editor, go Insert | User Form. You'll then have a form editor similar to VB6's. You can then add controls and code for that form. When you add Edit Controls (or any other controls for that matter) that you want to be able to tab to, make sure that each control has its Tab Stop property set to True. The Tab Index property determines the tab order.

 

To preselect text when you enter a text box, add something similar to the following to your text box's GotForus() sub:

 

code:

Private Sub WickedText_GotFocus()

WickedText.SelStart = 0

WickedText.SelLength = Len(WickedText.Text)

End Sub

HTH.

Link to comment
Share on other sites

Bullines,

I've got the form setup fine. 'Tab Stop' is True, 'Tab Index' is set for correct order.

 

The issue is that tabbing from field to field doesn't highlight the default value in the field. So you have to delete the default value or highlight the value and overwrite.

 

Is there a way to have the value highlight when you tab to the field?

Link to comment
Share on other sites

Hmmm, I know how to crete a control array in VB6. But how did you do it with VBA? What did you use to create the form? I don't think i follow what you've done.

 

code:

Private Sub txtParams_Enter(Index As Integer)

txtParams(Index).SelStart = 0

txtParams(Index).SelLength = Len(txtParams(Index).Text) '<- correction

End Sub

 

[ 08-12-2004, 07:20 PM: Message edited by: Bullines ]

Link to comment
Share on other sites

Steve,

 

I would create a function so that you don't have to write so much code in all of your textbox gotfocus events.

 

Module level function:

code:

Public Sub SelectAllText(p_Txt As TextBox)

 

On Error Resume Next

 

p_Txt.SelStart = 0

p_Txt.SelLength = Len(p_Txt.Text)

 

End Sub

One line of code is all we need now:

code:

Private Sub txtNestingOptions_GotFocus(Index As Integer)

SelectAllText txtNestingOptions(Index)

End Sub

Link to comment
Share on other sites

If we're talking VBA, that would be the only way, right Mick? I'm almost cetain that VBA doesn't directly support the creation of control arrays the way VB does. From poking around Office, I think that's true, what with all the ambiguity errors I got while trying to follow what Steve was trying wink.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...