Author Topic: New Project Step 1 Linetypes  (Read 6646 times)

0 Members and 1 Guest are viewing this topic.

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #15 on: July 08, 2005, 12:23:50 PM »
Quote from: daron
Heh. I did that for Linetypes property, but I do see where I was going wrong. No parens.
and no = sign needed either
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

daron

  • Guest
New Project Step 1 Linetypes
« Reply #16 on: July 08, 2005, 12:30:52 PM »
That too. I'd like to ask what's next, but I'd like to see the others who want to learn this stuff not fall behind. Are there any questions on how we got to the ThisDrawing module? Beuller?

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #17 on: July 08, 2005, 12:38:21 PM »
Whats next you ask.....  Well, what happens if you run your code twice?
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

daron

  • Guest
New Project Step 1 Linetypes
« Reply #18 on: July 08, 2005, 01:04:37 PM »
It errors because there is no On error resume next or something like that. actually, since I already had those loaded, they errored out in the first place.

daron

  • Guest
New Project Step 1 Linetypes
« Reply #19 on: July 08, 2005, 01:10:39 PM »
BTW, Dave, congrats on being able to control this place.

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #20 on: July 08, 2005, 01:19:59 PM »
Quote from: daron
BTW, Dave, congrats on being able to control this place.

Thanks, I was a mod at another site for a few years, so I asked Mark if I could mod this forum only.  When you posted your example with the code tag backwards, I was like..... eerrrrrggh, that is so frusterating not to be able to fix that.  Fortunetly you saw and fixed it.
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

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #21 on: July 08, 2005, 01:27:10 PM »
Quote from: daron
It errors because there is no On error resume next or something like that.

RIGHT!  Now a word about On Error Resume Next

Gurus can chime in if you disagree, but this is the worst kind of error checking in my opinion.  It does work, and it is better than nothing, but its the lazy way out.  Someday, you will have a situation where you need to catch the error and deal with it, and if you use this all the time, it will pass through and you will have no chance to fix the problem.

Now why did the example use it you ask?  Well, the people at Autodesk can in no way anticipate what you are going to do, and they know your going to copy and paste, so they put that in so when you run it for the first time, and your just learning VBA, it works.  Your linetypes load, your happy, and you move on.

So what is a better way of catching the error?  Use Select Case.

example to follow.
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

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #22 on: July 08, 2005, 02:18:26 PM »
For the LISPers out there, Select Case works like the COND statement in lisp.  From the Help File
Quote
Executes one of several groups of statements, depending on the value of an expression.

Syntax

Select Case testexpression
[Case expressionlist-n
[statements-n]] ...
[Case Else
[elsestatements]]

End Select


where the testexpression is what you are testing against.  the Case Expression is the match value, and the statements is what to do

so here is an example
Code: [Select]

Dim A as interger
A=3
Select Case A

Case 1:
Msgbox "A = 1"

Case 2:
Msgbox "A = 2"

Case 3:
Msgbox "A = 3"

Case Else:
Msgbox "A is not in the List"
End Select


Now there is more that would go into our error checking, but does everyone get the idea?
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

daron

  • Guest
New Project Step 1 Linetypes
« Reply #23 on: July 08, 2005, 02:49:24 PM »
I think so.

Birdy

  • Guest
New Project Step 1 Linetypes
« Reply #24 on: July 08, 2005, 03:26:11 PM »
<Not wanting to get left behind>
Yeah, been kinda following this thread, but gotta do a lotta work today too. :(
Will play a little catch-up this evening.

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #25 on: July 08, 2005, 03:42:23 PM »
Quote from: Birdy
<Not wanting to get left behind>

Im not going to cover much more today, as I want everyone who is following along to get a chance to work on this.  IF you are so inclined (or bored) this weekend, add an error checking function in our LoadLineType function.

Use the error number, and return a message box to the user saying its already loaded.  If any other number comes up, give the user a message box that has the error number and description.

There are good examples in the online help, and in the docs we have already posted in the Course forum.  Im avail for PM and email this weekend as well.
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

Birdy

  • Guest
New Project Step 1 Linetypes
« Reply #26 on: July 08, 2005, 03:48:36 PM »
:) thanks.

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #27 on: July 08, 2005, 10:00:04 PM »
i have had a family emergency come up and will probably be unavailable this weekend.  I will try and check in, but there is no guarentee.  See you guys on Monday
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

Mark

  • Custom Title
  • Seagull
  • Posts: 28683
New Project Step 1 Linetypes
« Reply #28 on: July 08, 2005, 10:06:47 PM »
Sorry to hear that David, see ya Monday.
TheSwamp.org  (serving the CAD community since 2003)

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
New Project Step 1 Linetypes
« Reply #29 on: July 08, 2005, 10:53:41 PM »
Ill give an update as I can
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