Form Help for a beginner

Form Help for a beginner

Anonymous
Not applicable
247 Views
4 Replies
Message 1 of 5

Form Help for a beginner

Anonymous
Not applicable
With the assistance of AcadX I am trying to begin the transition to the VBA world. I am posting using a web viewer so I apologize in advance for the format but I need help. The code locks up on setting the Ltest variable. Public Sub SelectLayer()

FrmLayerSelect.Show

End Sub

Private Sub UserForm_Activate()

Dim Elyr As AcadLayer
Dim Flyr As AcadLayer
Dim Blyr As AcadLayer

For Each Elyr In ThisDrawing.Layers
CboEdgeLayr.AddItem Elyr.Name
Next

For Each Flyr In ThisDrawing.Layers
CboFaceLayr.AddItem Flyr.Name
Next

For Each Blyr In ThisDrawing.Layers
CboBackLayr.AddItem Blyr.Name
Next


End Sub
Private Sub cmdCancel_Click()

Unload Me

End Sub
Private Sub cmdOK_Click()

Dim Ltest As Integer
Set Ltest = 0
If CboEdgeLayr.ListIndex <= -1 Then
Set Ltest = 1
End If
If CboFaceLayr.ListIndex <= -1 Then
Set Ltest = 2
End If
If CboBackLayr.ListIndex <= -1 Then
Set Ltest = 3
End If

If Ltest = 0 Then
ThisDrawing.SetVariable "USERS1", CboEdgeLayr.Text
ThisDrawing.SetVariable "USERS2", CboFaceLayr.Text
ThisDrawing.SetVariable "USERS3", CboBackLayr.Text
Unload Me
ElseIf Ltest = 1 Then
MsgBox "Please select an Edge of Pavement layer first", _
vbInformation, _
"Nothing selected"
ElseIf Ltest = 2 Then
MsgBox "Please select a Face of Curb layer first", _
vbInformation, _
"Nothing selected"
ElseIf Ltest = 3 Then
MsgBox "Please select a Back of Curb layer first", _
vbInformation, _
"Nothing selected"
End If

End Sub
0 Likes
248 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Since you're filling all three combos with all the layers, just use one
loop:

For Each layer in ThisDrawing.Layers
cbo1.AddItem layer.Name
cbo2.AddItem layer.Name
cbo3.AddItem layer.Name
Next

Also, I noticed you've Dim'ed LTEST as an Integer but you're using Set to
give it a value. Set is only for objects, not intrinsic data types.

--
http://www.acadx.com

Good judgement comes from experience.
Experience comes from bad judgement.


"jmodglin" wrote in message
news:f090910.-1@WebX.maYIadrTaRb...
0 Likes
Message 3 of 5

Anonymous
Not applicable
Joshua,

Don't use the Set statement. Only use Set when setting an object to a
variable. Don't feel bad, that has been a tough one for me also 🙂

Dim Ltest As Integer
Ltest = 0
If CboEdgeLayr.ListIndex <= -1 Then
Ltest = 1
End If
If CboFaceLayr.ListIndex <= -1 Then
Ltest = 2
etc...
--
Bobby C. Jones
http://www.acadx.com
0 Likes
Message 4 of 5

Anonymous
Not applicable
Thanks for your help AcadX. It works like a charm. I have a lot of routines that I will start building dialog box options for now. Here is a chance for some free advertising. What exactly is AcadX, besides being a great place for developers to have example code, articles to read, and links to other sites. What provides the financial support? Joshua Modglin
0 Likes
Message 5 of 5

Anonymous
Not applicable
Another question. With the above code, how would would I put these ComboBox lists in alphabetical order? I know that it has got to be connected with the TextBox Property but -1 through 2 does not work? I told you I was a beginner. Thanks for your help. Joshua Modglin
0 Likes