Using the GetDistance method

Using the GetDistance method

Anonymous
Not applicable
548 Views
11 Replies
Message 1 of 12

Using the GetDistance method

Anonymous
Not applicable
Is there a way to pass the value of a text box to the getdistanc e method?


Thanks in advance.
--
Rod Crowley
0 Likes
549 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
Value of a text box? I assume you mean the data is two points. Just
calculate it yourself. Try this http://code.acadx.com/visualbasic/013.htm

--
--
Ed
--
"Rodney Crowley" wrote in message
news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> Is there a way to pass the value of a text box to the getdistanc e method?
>
>
> Thanks in advance.
> --
> Rod Crowley
>
>
0 Likes
Message 3 of 12

Anonymous
Not applicable
Is this what you're looking for?

Public Sub showDistance()
Const TEXT_BOX_STRING = "10.0,15.0"

Dim basePoint(0 To 2) As Double
Dim commaPosition As Integer
Dim distance As Double
Dim tempString As String
Dim xValue As Integer
Dim yValue As Integer
Dim zValue As Integer

' Convert the text string into numbers and store in an array.
On Error GoTo HANDLE_ERROR
commaPosition = InStr(1, TEXT_BOX_STRING, ",")
If commaPosition = 0 Then
MsgBox "Invalid input."
Exit Sub
Else
xValue = CDbl(Left$(TEXT_BOX_STRING, commaPosition - 1))
tempString = Right$(TEXT_BOX_STRING, commaPosition + 1)
commaPosition = InStr(1, tempString, ",")
If commaPosition = 0 Then
yValue = CDbl(tempString)
zValue = 0#
Else
yValue = CDbl(Left$(TEXT_BOX_STRING, commaPosition - 1))
tempString = Right$(TEXT_BOX_STRING, commaPosition + 1)
zValue = CDbl(tempString)
End If
End If
On Error GoTo 0

basePoint(0) = xValue
basePoint(1) = yValue
basePoint(2) = zValue

distance = ThisDrawing.Utility.GetDistance(basePoint, "Select second point.")
MsgBox CStr(distance)
Exit Sub

HANDLE_ERROR:
MsgBox "Invalid input."

End Sub
0 Likes
Message 4 of 12

Anonymous
Not applicable
I am trying to take the value of a textbox, regardless of how it is entered,
and feed it into the getdistance method. In lisp if you pass a value through
the (getdist) function it will accept architectural units (1'-4 1/2"). I
would like to give my users the same option in vba, instead of writing a
function that will take 1'-4 1/2" and convert it to 16.5 I would rather pass
it through the getdistance method, something that does it for me already.



"Ed Jobe" wrote in message
news:F1596219339F86F7B9CB67CB2C459433@in.WebX.maYIadrTaRb...
> Value of a text box? I assume you mean the data is two points. Just
> calculate it yourself. Try this http://code.acadx.com/visualbasic/013.htm
>
> --
> --
> Ed
> --
> "Rodney Crowley" wrote in message
> news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> > Is there a way to pass the value of a text box to the getdistanc e
method?
> >
> >
> > Thanks in advance.
> > --
> > Rod Crowley
> >
> >
>
>
0 Likes
Message 5 of 12

Anonymous
Not applicable
Perhaps I don't understand you, but isn't (1'-4 1/2") already a distance?
The (getdist) function only accepts points, so it wouldn't accept (1'-4
1/2") without some reformatting.

--
--
Ed
--
"Rodney Crowley" wrote in message
news:A0D4FCEB309ABB4545A67C511A0371E1@in.WebX.maYIadrTaRb...
> I am trying to take the value of a textbox, regardless of how it is
entered,
> and feed it into the getdistance method. In lisp if you pass a value
through
> the (getdist) function it will accept architectural units (1'-4 1/2"). I
> would like to give my users the same option in vba, instead of writing a
> function that will take 1'-4 1/2" and convert it to 16.5 I would rather
pass
> it through the getdistance method, something that does it for me already.
>
>
>
> "Ed Jobe" wrote in message
> news:F1596219339F86F7B9CB67CB2C459433@in.WebX.maYIadrTaRb...
> > Value of a text box? I assume you mean the data is two points. Just
> > calculate it yourself. Try this
http://code.acadx.com/visualbasic/013.htm
> >
> > --
> > --
> > Ed
> > --
> > "Rodney Crowley" wrote in message
> > news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> > > Is there a way to pass the value of a text box to the getdistanc e
> method?
> > >
> > >
> > > Thanks in advance.
> > > --
> > > Rod Crowley
> > >
> > >
> >
> >
>
>
0 Likes
Message 6 of 12

Anonymous
Not applicable
I guess I am having trouble explaining what I am trying to do. with the
getdistance method, you can feed it a distance at the command line as an
alternative to picking points. I am looking to do the same thing, but
instead of from the command line, I would like it to pass it from a textbox.
when using the getdistance method from the command line, you can feed it a
value of 1'-4 1/2" and the get function will strip away all of the garbage
and store it as 16.5 in your variable. that is what i am trying to get.




"Ed Jobe" wrote in message
news:18BEEB741A04E8F74B6CE0A0DC1449D1@in.WebX.maYIadrTaRb...
> Perhaps I don't understand you, but isn't (1'-4 1/2") already a distance?
> The (getdist) function only accepts points, so it wouldn't accept (1'-4
> 1/2") without some reformatting.
>
> --
> --
> Ed
> --
> "Rodney Crowley" wrote in message
> news:A0D4FCEB309ABB4545A67C511A0371E1@in.WebX.maYIadrTaRb...
> > I am trying to take the value of a textbox, regardless of how it is
> entered,
> > and feed it into the getdistance method. In lisp if you pass a value
> through
> > the (getdist) function it will accept architectural units (1'-4 1/2"). I
> > would like to give my users the same option in vba, instead of writing a
> > function that will take 1'-4 1/2" and convert it to 16.5 I would rather
> pass
> > it through the getdistance method, something that does it for me
already.
> >
> >
> >
> > "Ed Jobe" wrote in message
> > news:F1596219339F86F7B9CB67CB2C459433@in.WebX.maYIadrTaRb...
> > > Value of a text box? I assume you mean the data is two points. Just
> > > calculate it yourself. Try this
> http://code.acadx.com/visualbasic/013.htm
> > >
> > > --
> > > --
> > > Ed
> > > --
> > > "Rodney Crowley" wrote in message
> > > news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> > > > Is there a way to pass the value of a text box to the getdistanc e
> > method?
> > > >
> > > >
> > > > Thanks in advance.
> > > > --
> > > > Rod Crowley
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 7 of 12

Anonymous
Not applicable
I think its sinking in now. I don't have time to try it, but how about the
SendKeys function?

--
--
Ed
--
"Rodney Crowley" wrote in message
news:D08C96B98C92438AE039707FEA8ED898@in.WebX.maYIadrTaRb...
> I guess I am having trouble explaining what I am trying to do. with the
> getdistance method, you can feed it a distance at the command line as an
> alternative to picking points. I am looking to do the same thing, but
> instead of from the command line, I would like it to pass it from a
textbox.
> when using the getdistance method from the command line, you can feed it a
> value of 1'-4 1/2" and the get function will strip away all of the garbage
> and store it as 16.5 in your variable. that is what i am trying to get.
>
>
>
>
> "Ed Jobe" wrote in message
> news:18BEEB741A04E8F74B6CE0A0DC1449D1@in.WebX.maYIadrTaRb...
> > Perhaps I don't understand you, but isn't (1'-4 1/2") already a
distance?
> > The (getdist) function only accepts points, so it wouldn't accept (1'-4
> > 1/2") without some reformatting.
> >
> > --
> > --
> > Ed
> > --
> > "Rodney Crowley" wrote in message
> > news:A0D4FCEB309ABB4545A67C511A0371E1@in.WebX.maYIadrTaRb...
> > > I am trying to take the value of a textbox, regardless of how it is
> > entered,
> > > and feed it into the getdistance method. In lisp if you pass a value
> > through
> > > the (getdist) function it will accept architectural units (1'-4 1/2").
I
> > > would like to give my users the same option in vba, instead of writing
a
> > > function that will take 1'-4 1/2" and convert it to 16.5 I would
rather
> > pass
> > > it through the getdistance method, something that does it for me
> already.
> > >
> > >
> > >
> > > "Ed Jobe" wrote in message
> > > news:F1596219339F86F7B9CB67CB2C459433@in.WebX.maYIadrTaRb...
> > > > Value of a text box? I assume you mean the data is two points. Just
> > > > calculate it yourself. Try this
> > http://code.acadx.com/visualbasic/013.htm
> > > >
> > > > --
> > > > --
> > > > Ed
> > > > --
> > > > "Rodney Crowley" wrote in message
> > > > news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> > > > > Is there a way to pass the value of a text box to the getdistanc e
> > > method?
> > > > >
> > > > >
> > > > > Thanks in advance.
> > > > > --
> > > > > Rod Crowley
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 8 of 12

Anonymous
Not applicable
I have considered that, but only as a last option.

Thanks!

"Ed Jobe" wrote in message
news:D7F9D8DC497815C62720924D43556F83@in.WebX.maYIadrTaRb...
> I think its sinking in now. I don't have time to try it, but how about the
> SendKeys function?
>
> --
> --
> Ed
> --
> "Rodney Crowley" wrote in message
> news:D08C96B98C92438AE039707FEA8ED898@in.WebX.maYIadrTaRb...
> > I guess I am having trouble explaining what I am trying to do. with the
> > getdistance method, you can feed it a distance at the command line as an
> > alternative to picking points. I am looking to do the same thing, but
> > instead of from the command line, I would like it to pass it from a
> textbox.
> > when using the getdistance method from the command line, you can feed it
a
> > value of 1'-4 1/2" and the get function will strip away all of the
garbage
> > and store it as 16.5 in your variable. that is what i am trying to get.
> >
> >
> >
> >
> > "Ed Jobe" wrote in message
> > news:18BEEB741A04E8F74B6CE0A0DC1449D1@in.WebX.maYIadrTaRb...
> > > Perhaps I don't understand you, but isn't (1'-4 1/2") already a
> distance?
> > > The (getdist) function only accepts points, so it wouldn't accept
(1'-4
> > > 1/2") without some reformatting.
> > >
> > > --
> > > --
> > > Ed
> > > --
> > > "Rodney Crowley" wrote in message
> > > news:A0D4FCEB309ABB4545A67C511A0371E1@in.WebX.maYIadrTaRb...
> > > > I am trying to take the value of a textbox, regardless of how it is
> > > entered,
> > > > and feed it into the getdistance method. In lisp if you pass a value
> > > through
> > > > the (getdist) function it will accept architectural units (1'-4
1/2").
> I
> > > > would like to give my users the same option in vba, instead of
writing
> a
> > > > function that will take 1'-4 1/2" and convert it to 16.5 I would
> rather
> > > pass
> > > > it through the getdistance method, something that does it for me
> > already.
> > > >
> > > >
> > > >
> > > > "Ed Jobe" wrote in message
> > > > news:F1596219339F86F7B9CB67CB2C459433@in.WebX.maYIadrTaRb...
> > > > > Value of a text box? I assume you mean the data is two points.
Just
> > > > > calculate it yourself. Try this
> > > http://code.acadx.com/visualbasic/013.htm
> > > > >
> > > > > --
> > > > > --
> > > > > Ed
> > > > > --
> > > > > "Rodney Crowley" wrote in message
> > > > > news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> > > > > > Is there a way to pass the value of a text box to the getdistanc
e
> > > > method?
> > > > > >
> > > > > >
> > > > > > Thanks in advance.
> > > > > > --
> > > > > > Rod Crowley
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 9 of 12

Anonymous
Not applicable
Rodney,
What you are looking for is the DistanceToReal method of the Utility object.
--
Bobby C. Jones
www.AcadX.com

"Rodney Crowley" wrote in message
news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> Is there a way to pass the value of a text box to the getdistanc e method?
>
>
> Thanks in advance.
> --
> Rod Crowley
>
>
0 Likes
Message 10 of 12

Anonymous
Not applicable
thank you! that is exactly what I am looking for!


"Bobby C. Jones" wrote in message
news:DCC555EAF361993DDEB92A71C316AA37@in.WebX.maYIadrTaRb...
> Rodney,
> What you are looking for is the DistanceToReal method of the Utility
object.
> --
> Bobby C. Jones
> www.AcadX.com
>
> "Rodney Crowley" wrote in message
> news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> > Is there a way to pass the value of a text box to the getdistanc e
method?
> >
> >
> > Thanks in advance.
> > --
> > Rod Crowley
> >
> >
>
>
0 Likes
Message 11 of 12

Anonymous
Not applicable
I knew that! 🙂 Too many things goin' on. I thought of it just after I hit
send but didn't even have time to reply.

--
--
Ed
--
"Rodney Crowley" wrote in message
news:C9D4515C3777867C7D67444CF02FF834@in.WebX.maYIadrTaRb...
> thank you! that is exactly what I am looking for!
>
>
> "Bobby C. Jones" wrote in message
> news:DCC555EAF361993DDEB92A71C316AA37@in.WebX.maYIadrTaRb...
> > Rodney,
> > What you are looking for is the DistanceToReal method of the Utility
> object.
> > --
> > Bobby C. Jones
> > www.AcadX.com
> >
> > "Rodney Crowley" wrote in message
> > news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
> > > Is there a way to pass the value of a text box to the getdistanc e
> method?
> > >
> > >
> > > Thanks in advance.
> > > --
> > > Rod Crowley
> > >
> > >
> >
> >
>
>
0 Likes
Message 12 of 12

Anonymous
Not applicable
You could use something similar to this to verify the input:

Public Function DistToReal(ByVal Text As String, ByVal FromUnit As Integer,
ByVal Reset As Double) As Double
Dim Dist As Double
If Text <> "0" Then
On Error Resume Next
Dist = ThisDrawing.Utility.DistanceToReal(Text, FromUnit)
Err.Clear
If Dist = 0 Then Dist = Reset
End If
DistToReal = Dist
End Function


--
R. Robert Bell, MCSE
www.AcadX.com


"Rodney Crowley" wrote in message
news:D29149A19C5A4A7DE16E9017D47D5CE8@in.WebX.maYIadrTaRb...
| I have considered that, but only as a last option.
|
| Thanks!
|
| "Ed Jobe" wrote in message
| news:D7F9D8DC497815C62720924D43556F83@in.WebX.maYIadrTaRb...
| > I think its sinking in now. I don't have time to try it, but how about
the
| > SendKeys function?
| >
| > --
| > --
| > Ed
| > --
| > "Rodney Crowley" wrote in message
| > news:D08C96B98C92438AE039707FEA8ED898@in.WebX.maYIadrTaRb...
| > > I guess I am having trouble explaining what I am trying to do. with
the
| > > getdistance method, you can feed it a distance at the command line as
an
| > > alternative to picking points. I am looking to do the same thing, but
| > > instead of from the command line, I would like it to pass it from a
| > textbox.
| > > when using the getdistance method from the command line, you can feed
it
| a
| > > value of 1'-4 1/2" and the get function will strip away all of the
| garbage
| > > and store it as 16.5 in your variable. that is what i am trying to
get.
| > >
| > >
| > >
| > >
| > > "Ed Jobe" wrote in message
| > > news:18BEEB741A04E8F74B6CE0A0DC1449D1@in.WebX.maYIadrTaRb...
| > > > Perhaps I don't understand you, but isn't (1'-4 1/2") already a
| > distance?
| > > > The (getdist) function only accepts points, so it wouldn't accept
| (1'-4
| > > > 1/2") without some reformatting.
| > > >
| > > > --
| > > > --
| > > > Ed
| > > > --
| > > > "Rodney Crowley" wrote in message
| > > > news:A0D4FCEB309ABB4545A67C511A0371E1@in.WebX.maYIadrTaRb...
| > > > > I am trying to take the value of a textbox, regardless of how it
is
| > > > entered,
| > > > > and feed it into the getdistance method. In lisp if you pass a
value
| > > > through
| > > > > the (getdist) function it will accept architectural units (1'-4
| 1/2").
| > I
| > > > > would like to give my users the same option in vba, instead of
| writing
| > a
| > > > > function that will take 1'-4 1/2" and convert it to 16.5 I would
| > rather
| > > > pass
| > > > > it through the getdistance method, something that does it for me
| > > already.
| > > > >
| > > > >
| > > > >
| > > > > "Ed Jobe" wrote in message
| > > > > news:F1596219339F86F7B9CB67CB2C459433@in.WebX.maYIadrTaRb...
| > > > > > Value of a text box? I assume you mean the data is two points.
| Just
| > > > > > calculate it yourself. Try this
| > > > http://code.acadx.com/visualbasic/013.htm
| > > > > >
| > > > > > --
| > > > > > --
| > > > > > Ed
| > > > > > --
| > > > > > "Rodney Crowley" wrote in message
| > > > > > news:B34523D4807EE870EB5B7A33E026CDF8@in.WebX.maYIadrTaRb...
| > > > > > > Is there a way to pass the value of a text box to the
getdistanc
| e
| > > > > method?
| > > > > > >
| > > > > > >
| > > > > > > Thanks in advance.
| > > > > > > --
| > > > > > > Rod Crowley
| > > > > > >
| > > > > > >
| > > > > >
| > > > > >
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
0 Likes