If ... then

If ... then

Anonymous
Not applicable
498 Views
15 Replies
Message 1 of 16

If ... then

Anonymous
Not applicable
Hi,

I need some help,

I want to program the following things:

if value 1 <= 3300 then
x = 44
y = 142

if 3300 < value 1 <=3800 then
x = 58
y = 170

if 3800 < value 1 <= 5100 then
x = 58
y = 192

I did program this one, but when I use it to draw, then autocad always uses the last one (58, 192) even if my value 1 is <3300.

How do I progrm it right?

thx
0 Likes
499 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable
Firstly, if you are trying to use "value 1" as a variable name, it is not
allowed because of the space. Replace "value 1" with "value1" in your
program.

Second... here's your If-Then in a working format.

' make sure you handle value1 < 0, unless you know that
' it could never happen
if value1 <= 3300 then
x = 44
y = 142
elseif value1 <=3800 then 'you know it's > 3300
x = 58
y = 170
elseif value1 <= 5100 then 'you know it's > 3800
x = 58
y = 192
else
'you should handle value1 > 5100, unless
' you know it could never happen
endif

Good luck,
James
0 Likes
Message 3 of 16

Anonymous
Not applicable
Quick fingers James beat me (and I would defer to his expertise any day) but
just for variety (and since I already wrote this out and tried it....)

Sub TEST2()
Dim VALUE1 As Integer
VALUE1 = 5550

Dim X As Integer
Dim Y As Integer

Select Case VALUE1
Case Is <= 3300

'if value 1 <= 3300 then
X = 44
Y = 142

dp X
dp Y

Case Is <= 3800

'if 3300 < value 1 <=3800 then
X = 58
Y = 170
dp X
dp Y

Case Is <= 5100

'if 3800 < value 1 <= 5100 then
X = 58
Y = 192

dp X
dp Y
Case Else
dp "OTHER"

End Select

End Sub

sub dp(str)
debug.print str
end sub

hth
Mark

"SabrinaCollstrop" wrote in message
news:f16e3e6.-1@WebX.maYIadrTaRb...
> Hi,
> I need some help,
>
> I want to program the following things:
>
> if value 1 <= 3300 then
> x = 44
> y = 142
>
> if 3300 < value 1 <=3800 then
> x = 58
> y = 170
>
> if 3800 < value 1 <= 5100 then
> x = 58
> y = 192
>
> I did program this one, but when I use it to draw, then autocad always
uses the last one (58, 192) even if my value 1 is <3300.
>
> How do I progrm it right?
>
> thx
>
>
0 Likes
Message 4 of 16

Anonymous
Not applicable
Sabrina,

Aside from the variable name problem, it sounds
like

a select case would be more appropriate than
an if statement:

 

Select case value1

case is <= 3300

x = 44

y = 142

case is <=3800

x = 58

y = 170

case is <=5100

x = 58

y = 192

case else

'here you can put the default condtion

end select

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,

I need some help,

I want to program the following things:

if value 1 <= 3300 then
x = 44
y = 142

if 3300 < value 1 <=3800 then
x = 58
y = 170

if 3800 < value 1 <= 5100 then
x = 58
y = 192

I did program this one, but when I use it to draw, then autocad always uses
the last one (58, 192) even if my value 1 is <3300.

How do I progrm it right?

thx

0 Likes
Message 5 of 16

Anonymous
Not applicable
The draw of the dark side is powerful
<g>
--
Bobby C. Jones

href="http://www.AcadX.com">www.AcadX.com


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Sabrina,

Aside from the variable name problem, it sounds
like

a select case would be more appropriate than
an if statement:

 

Select case value1

case is <= 3300

x = 44

y = 142

case is <=3800

x = 58

y = 170

case is <=5100

x = 58

y = 192

case else

'here you can put the default
condtion

end select

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,

I need some help,

I want to program the following things:

if value 1 <= 3300 then
x = 44
y = 142

if 3300 < value 1 <=3800 then
x = 58
y = 170

if 3800 < value 1 <= 5100 then
x = 58
y = 192

I did program this one, but when I use it to draw, then autocad always
uses the last one (58, 192) even if my value 1 is <3300.

How do I progrm it right?

thx

0 Likes
Message 6 of 16

Anonymous
Not applicable
great minds work alike!
:-)
ha ha

"Doug Broad" wrote in message
news:CED30DCE21C047AE68FC41577A31A0DF@in.WebX.maYIadrTaRb...
> Sabrina,
> Aside from the variable name problem, it sounds like
> a select case would be more appropriate than an if statement:
0 Likes
Message 7 of 16

Anonymous
Not applicable
Sorry Mark,
I should have looked at your post more closely. My
post seems superfluous. 😉
Doug

"Mark Propst" wrote in message
news:73A7B48119BE123C267FA5673EEEFCB8@in.WebX.maYIadrTaRb...
> great minds work alike!
> 🙂
> ha ha
>
> "Doug Broad" wrote in message
> news:CED30DCE21C047AE68FC41577A31A0DF@in.WebX.maYIadrTaRb...
> > Sabrina,
> > Aside from the variable name problem, it sounds like
> > a select case would be more appropriate than an if statement:
>
>
>
0 Likes
Message 8 of 16

Anonymous
Not applicable
Yes Master Bobby,
Hmmm.  You need a more
imposing moniker. 😉


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

The draw of the dark side is powerful
<g>
--
Bobby C. Jones

href="http://www.AcadX.com">www.AcadX.com


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<snip>
0 Likes
Message 9 of 16

Anonymous
Not applicable
Far from it!
I'm relieved to have my 'wild axx guess' confirmed by someone of your
stature!
Always glad to hear your view!
Mark

"Doug Broad" wrote in message
news:D8EF6F74CBC80D4394D0830C8E5FD4AA@in.WebX.maYIadrTaRb...
> Sorry Mark,
> I should have looked at your post more closely. My
> post seems superfluous. 😉
> Doug
0 Likes
Message 10 of 16

Anonymous
Not applicable
baba bobby?

"Doug Broad" wrote in message
news:528FCAFBC818DF2B46B3B8B0D1386CEC@in.WebX.maYIadrTaRb...
> Yes Master Bobby,
> Hmmm. You need a more imposing moniker. 😉
> "Bobby C. Jones" wrote in message
news:E48448F901BDE8CDF9DA6944A35B8057@in.WebX.maYIadrTaRb...
> The draw of the dark side is powerful
> --
> Bobby C. Jones
> www.AcadX.com
>
>
0 Likes
Message 11 of 16

Anonymous
Not applicable
Mark,
I don't know whether DP is actually a utility you use or just something you
wrote this one time, but I thought it was nifty and couldn't resist adding
to it.

I know I should just throw this e-mail out to spare myself the
embarrassment, but maybe I can save someone, somewhere, from Debug.Print
"carpal tunnel"... and yes, I know that with Auto-Complete it only takes
about 5 keystrokes to debug.print something anyway 🙂

Hmmm... this might be the start of a Development_Utility module that I bring
into new projects ...

James


Sub dp(ParamArray strs() As Variant)
Dim i As Long
If UBound(strs) = -1 Then Debug.Print: Exit Sub
For i = LBound(strs) To (UBound(strs) - 1)
Debug.Print strs(i) & ", ";
Next
Debug.Print strs(UBound(strs)) & ""
End Sub

Sub testDP()
Dim x As String, y As Double
x = "xxxx": y = "1234.12958"
dp x
dp
dp x, y, x, y
End Sub
0 Likes
Message 12 of 16

Anonymous
Not applicable
Anybody have any idea how to parse this XML document?



Big Imposing Scary Bob
Not my favorite. It just doesn't have a ring to it.


baba bobby
If this one sticks, I'm hunting you down Mark!


Stress Ball Buster
Take this one where you want...but probably not on this
server.

big


--
Bobby C. Jones
www.AcadX.com

"Mark Propst" wrote in message
news:1EEFB69EBAE8E7E16A46A501894E6714@in.WebX.maYIadrTaRb...
> baba bobby?
>
> "Doug Broad" wrote in message
> news:528FCAFBC818DF2B46B3B8B0D1386CEC@in.WebX.maYIadrTaRb...
> > Yes Master Bobby,
> > Hmmm. You need a more imposing moniker. 😉
> > "Bobby C. Jones" wrote in message
> news:E48448F901BDE8CDF9DA6944A35B8057@in.WebX.maYIadrTaRb...
> > The draw of the dark side is powerful
> > --
> > Bobby C. Jones
> > www.AcadX.com
> >
> >
>
>
0 Likes
Message 13 of 16

Anonymous
Not applicable
ROFLOL. Babba Bob. Has a ring to it.

"Bobby C. Jones" wrote in message
news:160D1C9A7BA9232ED67EC529720A7190@in.WebX.maYIadrTaRb...
> Anybody have any idea how to parse this XML document?
>
>
0 Likes
Message 14 of 16

Anonymous
Not applicable
this must be one of those symbiotic moments

Actually, the one i really use is
Sub dp(str)
Dim doc As AcadDocument
Set doc = ThisDrawing

Debug.Print str
doc.Utility.prompt vbCrLf & str & vbCrLf

Set doc = Nothing
End Sub

and i've been wanting to add the automatic parsing of a point value but
haven't got around to it,
thanks for the momentum!

dp revised:
Option Compare Text
Option Explicit

Sub dp(str)
Dim doc As AcadDocument
Set doc = ThisDrawing
Dim i As Integer
Debug.Print TypeName(str)
Dim pointstr As String
pointstr = ""

If TypeName(str) = "string" Then
Debug.Print str
doc.Utility.prompt vbCrLf & str
ElseIf TypeName(str) = "variant()" Then
If UBound(str) > 0 Then
For i = LBound(str) To UBound(str) - 1
pointstr = pointstr & str(i) & ", "
Next i
pointstr = pointstr & str(i)
Debug.Print pointstr
doc.Utility.prompt vbCrLf & pointstr & vbCrLf
End If
End If
Set doc = Nothing
End Sub

Mark


"James Belshan" wrote in message
news:F71B1B21D6445C773542574E57DA025B@in.WebX.maYIadrTaRb...
> Mark,
> I don't know whether DP is actually a utility you use or just something
you
> wrote this one time, but I thought it was nifty and couldn't resist adding
> to it.
>
> I know I should just throw this e-mail out to spare myself the
> embarrassment, but maybe I can save someone, somewhere, from Debug.Print
> "carpal tunnel"... and yes, I know that with Auto-Complete it only takes
> about 5 keystrokes to debug.print something anyway 🙂
>
> Hmmm... this might be the start of a Development_Utility module that I
bring
> into new projects ...
>
> James
>
>
> Sub dp(ParamArray strs() As Variant)
> Dim i As Long
> If UBound(strs) = -1 Then Debug.Print: Exit Sub
> For i = LBound(strs) To (UBound(strs) - 1)
> Debug.Print strs(i) & ", ";
> Next
> Debug.Print strs(UBound(strs)) & ""
> End Sub
>
> Sub testDP()
> Dim x As String, y As Double
> x = "xxxx": y = "1234.12958"
> dp x
> dp
> dp x, y, x, y
> End Sub
>
>
>
0 Likes
Message 15 of 16

Anonymous
Not applicable
My current AutoCAD VBA stature: Knee high to a grasshopper.
I'll try to live up to your expectations. 😉

"Mark Propst" wrote in message
news:1E9425F743BF67AD726407EB2F1C656E@in.WebX.maYIadrTaRb...
> Far from it!
> I'm relieved to have my 'wild axx guess' confirmed by someone of your
> stature!
> Always glad to hear your view!
> Mark
0 Likes
Message 16 of 16

Anonymous
Not applicable
"Mark Propst" wrote in message
news:9658067EE305A4FE71B81CEC62DDE6C3@in.WebX.maYIadrTaRb...
> this must be one of those symbiotic moments
> dp revised:

revised again:

Sub dp(str)
Dim doc As AcadDocument
Set doc = ThisDrawing
Dim i As Integer
Dim pointstr As String
pointstr = ""

If TypeName(str) = "string" Then
Debug.Print str
doc.Utility.prompt vbCrLf & str
ElseIf Right((TypeName(str)), 2) = "()" Then
If UBound(str) > 0 Then
For i = LBound(str) To UBound(str) - 1
pointstr = pointstr & str(i) & ", "
Next i
pointstr = pointstr & str(i)
Debug.Print pointstr
doc.Utility.prompt vbCrLf & pointstr & vbCrLf
End If
End If
Set doc = Nothing
End Sub
0 Likes