PDA

View Full Version : VBA (AutoCAD) Userforms


ScottBolton
12-08-2005, 11:16 AM
I've having some problems with tags for some userform objects.

This code (should) read a line of text from a file (passed from a LISP expression) and if it equals "insert" then the "Insert" optionbutton should be given focus. This does happen but the black dot in the button isn't visible, just the outline around the text.

Sub BTnorthpointopen()
Dim Northpoint As String
Dim FileNumber As Integer
FileNumber = FreeFile
Open "D:\dclinput.tmp" For Input As #FileNumber
Line Input #FileNumber, Northpoint
Close #FileNumber
If Northpoint = "insert" Then
BTnorthpointscreen.Insert.Value = True
Else
BTnorthpointscreen.Insert.Value = True
End If
BTnorthpointscreen.Show
End Sub

I've also played around with:

BTnorthpointscreen.Insert.TabIndex = 0
BTnorthpointscreen.Rotate.TabIndex = 1

but no joy.

And there's more!

I can't get a label to have a tabstop despite changing the flag to True and giving it a tab index. The flag is changed back to False when I display the form.

Any clues?

S

TCARPENTER
15-08-2005, 11:44 AM
Hi Scott,

Unfortuneatly, unless you want to create your form programically, and set your default value to true, I don't believe your option button will respond the way you are hoping. Maybe you could switch your option buttons to a combo box and have whatever value your option button represented, be the default in your combo box?

Also, your tabstops don't apply to labels in VBA. If you need this for some reason, change your label to a text box and just change it's properties to appear as a label.

HTH
Todd

ScottBolton
15-08-2005, 07:39 PM
Thanks Todd, I'll give your recommendations a bash tomorrow.

S

hendie
19-08-2005, 11:32 AM
the option button should change if you have the correct value ~ but you must have an exact match... and it is case sensitive

try this:
If ucase(Northpoint) = "INSERT" Then

you may also want to add a trim() method in there too, incase someone has added an extra space at the end of "insert "

ScottBolton
22-08-2005, 07:31 PM
Thanks, Hendie. I write the "insert" myself so I don't need the ucase command, though it'll come in useful in the near future.

S