PDA

View Full Version : Got problem with select case



Adesu
2008-07-09, 12:37 AM
HI All,
here my code to create line and circle with select option, I still confuse in function select case,
please guide me to become true way.
I very appreaciated for your help.


Sub test1()

Dim ObjLin As AcadLine
Dim ObjCir As AcadCircle
Dim Pt As Variant
Dim Opt As String
Dim StartPnt As Variant
Dim EndPnt As Variant
Dim Rad As Variant


StartPnt = ThisDrawing.Utility.GetPoint(, "Click any location as base point ")
Opt = ThisDrawing.Utility.GetString(1, vbCrLf & "Enter (L)ine or (C)ircle: ")
Opt = UCase(Opt)

Select Case Opt
Case "L"
EndPnt = ThisDrawing.Utility.PolarPoint(StartPnt, 0, 100)
Set ObjLin = ThisDrawing.ModelSpace.AddLine(StartPnt, EndPnt)

Case "C"
Rad = ThisDrawing.Utility.PolarPoint(StartPnt, 0, 10)
Set ObjCir = ThisDrawing.ModelSpace.AddCircle(StartPnt, Rad)

Case Else
If Not ("L" And "C") Then MsgBox "Invalid selected option"

End Select

End Sub

fixo
2008-07-09, 03:04 AM
You cross posted
See this article:
http://www.excelguru.ca/node/7
Scroll down half page and read this chapter:
"How to post and when to cross-post"

~'J'~

Adesu
2008-07-10, 02:50 AM
I got it, here my code


Sub ssc()

Dim ObjLin As AcadLine
Dim ObjCir As AcadCircle
Dim Pt As Variant
Dim Opt As String
Dim StartPnt As Variant
Dim EndPnt As Variant
Dim Rad As Variant
Dim EndPoint As Variant

StartPnt = ThisDrawing.Utility.GetPoint(, "Click any location as base point ")
Opt = ThisDrawing.Utility.GetString(1, vbCrLf & "Enter (L)ine or (C)ircle: ")
Opt = UCase(Opt)
Select Case Opt
Case "L" '1).
EndPnt = ThisDrawing.Utility.PolarPoint(StartPnt, 0, 100)
Set ObjLin = ThisDrawing.ModelSpace.AddLine(StartPnt, EndPnt)

Case "C" '1).
EndPoint = ThisDrawing.Utility.PolarPoint(StartPnt, 0, 10)
Rad = DistBetweenPts(StartPnt, EndPoint)
Set ObjCir = ThisDrawing.ModelSpace.AddCircle(StartPnt, Rad)

Case Else
MsgBox "Invalid selected" '2).
End Select

End Sub