Author Topic: How to display coordinate in userform  (Read 5006 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to display coordinate in userform
« on: September 16, 2009, 03:26:46 AM »
I would create a code in vba, replace old code to new code, at old code coordinate the object display at massagebox, but for new code i want displace at userform, as example i have a line from coordinate 0,0,0 to 10,5,0.
How to display coordinate start point and end point ?
here my old code
Code: [Select]
Sub sgcc()

Dim ObjEnt As AcadEntity
Dim Pt As Variant

ThisDrawing.Utility.GetEntity ObjEnt, Pt, "Pick an object"

Dim PtX As Double
Dim PtY As Double
Dim PtZ As Double

PtX = Pt(0)
PtY = Pt(1)
PtZ = Pt(2)

MsgBox "Coordinate X is = " & PtX _
& vbCr & "Coordinate X is = " & PtY _
& vbCr & "Coordinate X is = " & PtZ

End Sub

« Last Edit: September 22, 2009, 01:01:03 AM by Adesu »

Humbertogo

  • Guest
Re: How to display coordinate in userform
« Reply #1 on: October 23, 2009, 03:10:56 AM »
something like the dist Command ?
Measures the distance and angle between two points

Adesu

  • Guest
Re: How to display coordinate in userform
« Reply #2 on: October 23, 2009, 08:30:26 AM »
Thanks for reply, I mean like this

Code: [Select]
Private Sub TextBox1_Change()
"what code for place coordinate"
End Sub

And look at attach file.


something like the dist Command ?
Measures the distance and angle between two points

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
Re: How to display coordinate in userform
« Reply #3 on: October 23, 2009, 09:27:00 AM »
are you wanting to type in the coords in the box or pick the entity and have it put the picked points in the box?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

Adesu

  • Guest
Re: How to display coordinate in userform
« Reply #4 on: October 23, 2009, 09:28:13 PM »
Yes that right "pick the entity and have it put the picked points in the box"



are you wanting to type in the coords in the box or pick the entity and have it put the picked points in the box?

Adesu

  • Guest
Re: How to display coordinate in userform
« Reply #5 on: February 21, 2010, 09:25:07 PM »
Hi,
Here new code to display coordinate startpoint and endpoint of line, but sorry this still error, it display error like this "Run-time 'error 424: object requied', would you please guide me to fix it.
Code: [Select]
' ppdc is stand for Pick Line Display Coordinates
'        Design by  : Adesu <Ade Suharna>
'        Email      : adesu@tentangcad.com
'                     adesu@telkom.net
'                     abahadethea@yahoo.co.id
'        Homepage   : http://cadesu.multiply.com
'        Create     : 22 February 2010
'        Program no.: 00xx/02/2010
'        Edit by    :
Sub pldc()
Dim objPicked As AcadLine
Dim Pt As Variant
ThisDrawing.Utility.GetEntity objPicked, Pt, "Pick an object line"
UserForm1.TextBox1.text = objPicked.StartPoint(0)
UserForm1.TextBox2.text = objPicked.StartPoint(1)
UserForm1.TextBox3.text = objPicked.StartPoint(2)
UserForm1.TextBox4.text = objPicked.EndPoint(0)
UserForm1.TextBox5.text = objPicked.EndPoint(1)
UserForm1.TextBox6.text = objPicked.EndPoint(2)
UserForm1.Show
End Sub

here code for userform
Code: [Select]
Private Sub CommandButton2_Click()
End
End Sub
Private Sub UserForm_Activate()

UserForm1.TextBox1.SetFocus
UserForm1.TextBox2.SetFocus
UserForm1.TextBox3.SetFocus
UserForm1.TextBox4.SetFocus
UserForm1.TextBox5.SetFocus
UserForm1.TextBox6.SetFocus

End Sub

Private Sub CommandButton1_Click()
objPicked.StartPoint(0) = TextBox1.Visible
objPicked.StartPoint(1) = TextBox2.Visible
objPicked.StartPoint(2) = TextBox3.Visible
objPicked.EndPoint(0) = TextBox4.Visible
objPicked.EndPoint(1) = TextBox5.Visible
objPicked.EndPoint(2) = TextBox6.Visible
   
End Sub

Yes that right "pick the entity and have it put the picked points in the box"



are you wanting to type in the coords in the box or pick the entity and have it put the picked points in the box?

bsardeson

  • Guest
Re: How to display coordinate in userform
« Reply #6 on: December 27, 2010, 10:55:23 AM »
The user form code will provide the Error Message "Runtime error 424: object Required" because of the following.

Private Sub CommandButton1_Click()
objPicked.StartPoint(0) = TextBox1.Visible

objPicked is not a global reference variable therefore cannot be used in this SUB, therefore error message.

Additionally, the example code provided by Adesu is attempting to set the visibility of the form controls = the startpoint and endpoint values.  Not sure why this is being done, but since it is, all values will be the binary result of the .Visible for each textbox control.  The example code, will be setting both the startpoint and endpoint to -1,-1,-1 and this isn't good, a line cannot have the endpoint and startpoint at the same place in space.