Jump to content

VBA Displaying Pick point coordinates in UserForm Text box


scubastu

Recommended Posts

Hi CADaholics,

 

I am just starting vba and I have designed a UserForm with combination text and command buttons. There is a Pick button to let user pick a point in Graphics screen and return to Userform. How do I get the coordinates to display in the Northing textbox, Easting textbox etc.. e.g set the value of the textbox with the right variable and display it.

 

I have actually already written the program in Lisp but would like to go vba or maybe dcl would be easier?

 

Thanks

 

Scuba

Link to comment
Share on other sites

Hi CADaholics,

 

I am just starting vba and I have designed a UserForm with combination text and command buttons. There is a Pick button to let user pick a point in Graphics screen and return to Userform. How do I get the coordinates to display in the Northing textbox, Easting textbox etc.. e.g set the value of the textbox with the right variable and display it.

 

I have actually already written the program in Lisp but would like to go vba or maybe dcl would be easier?

 

Thanks

 

Scuba

 

Please post the code you have written in an effort to resolve the problem,

and our members would be happy to provide some guidance.

Be sure to include a description of any errors you are encountering as well.

 

~'J'~

Link to comment
Share on other sites

Ok I got this from autocad2006 VBA book by Joe Sutphin.

It works ok I think but I want the resulting coordinates from the pick point physically displayed in the right text boxes on the User form.

Do I write something under txt1X_change()?

 

In other words, give the user a chance to write coordinates in or pick coordinates from ACAD graphics screen.

 

Private Sub cmdPick_Click()

Dim Point As Variant

On Error Resume Next

'hide the UserForm

Traverse.Hide

'ask user to select a point

Point = ThisDrawing.Utility.GetPoint(, "Select a Point")

If Err Then Exit Sub

'assign values to appropriate textbox

txt1X = Point(0): txt1Y = Point(1): txt1Z = Point(2)

'redisplay the UserForm

Traverse.Show

End Sub

Link to comment
Share on other sites

If the “txt1” refer to textbox then this should work:

 

Traverse.txt1X.Text = Cstr(Point(0))

Traverse.txt1Y.Text = Cstr(Point(1))

Traverse.txt1Z.Text = Cstr(Point(2))

 

VBA would likely do the type conversion for you, but an explicit Cstr() can’t hurt.

Link to comment
Share on other sites

If the “txt1” refer to textbox then this should work:

 

Traverse.txt1X.Text = Cstr(Point(0))

Traverse.txt1Y.Text = Cstr(Point(1))

Traverse.txt1Z.Text = Cstr(Point(2))

 

VBA would likely do the type conversion for you, but an explicit Cstr() can’t hurt.

 

 

Hey Thanks alot Seant! thats perfect! was probably pretty simple but now I can confuse my brain even more and try and write the rest!:wink:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...