Macro question
Macro question
(OP)
I have downloaded a macro that works with the custom and configuration specific properties in solidworks. My company requires certain data to be entered into both of these fields. I have managed to get the macro customized to where it is somewhat useful to our company. Keep in mind that I am very new to the macro/Visual Basic world. However I want to be able to scroll through the properties that are displayed in the user form by hitting the enter key on my keyboard. The way it is set up now I have to select the field in which I want to modify and then hit the TAB key twice to get to the entry field. I would like to click on the property in which I want to modify and then type the info I need and hit the enter key and it will automatically scroll to the next property and I can type the info again. I hope this makes sense to all you macro users. I can send the file to you if you would like to mess with it. I have tried several things and still can't seem to get it right.






RE: Macro question
Which control it moves to is defined by the "TabIndex" property.
RE: Macro question
Bradley
RE: Macro question
RE: Macro question
Do not use CAPS. Sounds like you are yelling.
Try setting your TabIndex in the Properties, in the order you want the “enter” to go. Zero for 1st, 1 for second and etc. If that works, we will go for more.
Bradley
RE: Macro question
I will try that and get back to you at a later date. have alot on my plate today so maybe sometime next week.
RE: Macro question
Here is the code I used with TabIndex set to 0, 1, 2. Worked better than I thought.
Option Explicit
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub TextBox3_Change()
End Sub
Private Sub UserForm_Click()
End Sub
Bradley
RE: Macro question
The code you posted above does not do anything... (?)
For example...
CODE
End Sub
Change is the Event that is Fired when you make a change to TextBox1...
If you want to use this event...
(for example forcing Lower Case or Upper Case letters)
You Could Do Something like this:
CODE
Dim Curs As Integer, CursLen As Integer
Curs = TextBox1.SelStart 'Preserve Cursor Position
CursLen = TextBox1.SelLength 'Preserve Selection Length
TextBox1.Text = UCase(TextBox1.Text) 'Make text UpperCase
TextBox1.SelStart = Curs 'Restore Cursor Position
TextBox1.SelLength = CursLen 'Restore Selection Length
End Sub
Private Sub TextBox2_Change()
Dim Curs As Integer, CursLen As Integer
Curs = TextBox2.SelStart 'Preserve Cursor Position
CursLen = TextBox2.SelLength 'Preserve Selection Length
TextBox1.Text = LCase(TextBox2.Text) 'Make text LowerCase
TextBox2.SelStart = Curs 'Restore Cursor Position
TextBox2.SelLength = CursLen 'Restore Selection Length
End Sub
Otherwise, you don't need that code...
When dealing with computers, there are 10 things you need to know: one, zero, and the rest is Binary.
-Josh S
RE: Macro question
RE: Macro question
In VB6 you are right, that what I thought for VBA within SolidWorks. Wrote the code above and just pressing “enter key” after typing in some junk text moved me to my next text box. Worked really cool.
SWVB101,
You are right about the events. My example was to show that with the enter key being pressed you would move to the next text box. Now I would wander if I wanted two lines of text in the one text box would I have to hold the control down?
Bradley
RE: Macro question
Right click on the textbox and select properties (if they are not already shown)
Go down to the M's and find MultiLine.
It should be set to False by default.
Double click it to set it to true, then you can use enter to go to the next line, and put as many lines as you want...
When dealing with computers, there are 10 things you need to know: one, zero, and the rest is Binary.
-Josh S