![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | What value should Err.Number be if there's no error Hi, It may sound like a dumb question but if there's no error condition what value should I expect to find? Should it be zero? Andy |
My System Specs![]() |
| | #2 (permalink) |
| | Re: What value should Err.Number be if there's no error > It may sound like a dumb question but if there's no error condition Quote: > what value should I expect to find? Should it be zero? > to makr sure it's zero before an operation by using Err.Clear. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: What value should Err.Number be if there's no error "mayayana" <mayaXXyana@xxxxxx> wrote in message news:euh%23m8YKJHA.740@xxxxxx Quote: Quote: >> It may sound like a dumb question but if there's no error condition >> what value should I expect to find? Should it be zero? >> > to makr sure it's zero before an operation by > using Err.Clear. itself: if err.number then wscript.echo "an error occurred" else wscript.echo "NO error occurred" end if When treated as a boolean, err.number takes on the value "an error has occurred", as zero is interpreted as false, whereas all non-zero values are interpreted as true. /Al |
My System Specs![]() |
| | #4 (permalink) |
| | Re: What value should Err.Number be if there's no error On Oct 8, 3:47*pm, "mayayana" <mayaXXy...@xxxxxx> wrote: Quote: Quote: > > It may sound like a dumb question but if there's no error condition > > what value should I expect to find? *Should it be zero? > * Yes, it's zero. You can also clear the error > to makr sure it's zero before an operation by > using Err.Clear. If Err.Number = Empty Then MsgBox "Err.Number is empty" End If Right? If this is right, what does it mean if the condition is true as I'm seeing in my environment? Andy |
My System Specs![]() |
| | #5 (permalink) |
| | Re: What value should Err.Number be if there's no error Empty is not numeric. It tests for an uninitialized variable. Err.Number is numeric. I think you may have just come across a quirk due to wrong syntax. You can use: If Err.Number = 0 Then And as Al pointed out, if you prefer terse code you can also use: If Err.Number Then '-- true if Err.Number <> 0 or If Not Err.Number Then '-- True if Err.Number = 0 I just tried this code: MsgBox IsEmpty(Err.Number) '-- Empty = 9 MsgBox Err.Number = Empty It returns False, True -- as you pointed out. I think maybe the third line is being interpreted by seeing "Empty" as a numeric variable. So 0 = 0. True. Yet if I uncomment the second line it causes an error because Empty is a keyword. So what you found doesn't really make sense. But it's also not relevant, since Empty is not applicable to Err.Number. (Err.Number is a property of the Err object, so it can't be an uninitialized variable.) Just treat Err.Number as a numeric value and you'll be fine. Quote: > If Err.Number = Empty Then MsgBox "Err.Number is empty" End If Right? If this is right, what does it mean if the condition is true as I'm seeing in my environment? Andy |
My System Specs![]() |
| | #6 (permalink) |
| | Re: What value should Err.Number be if there's no error On Oct 9, 9:56*am, "mayayana" <mayaXXy...@xxxxxx> wrote: Quote: > * Empty is not numeric. It tests for an uninitialized > variable. Err.Number is numeric. I think you may have > just come across a quirk due to wrong syntax. > > You can use: > If Err.Number = 0 Then > > And as Al pointed out, if you prefer terse code you > can also use: > > If Err.Number Then *'-- true if Err.Number <> 0 > > or > > If Not Err.Number Then *'-- True if Err.Number = 0 > > I just tried this code: > > MsgBox IsEmpty(Err.Number) > '-- Empty = 9 > MsgBox Err.Number = Empty > > It returns False, True -- as you pointed out. > I think maybe the third line is being interpreted > by seeing "Empty" as a numeric variable. So 0 = 0. True. > Yet if I uncomment the second line it causes an error > because Empty is a keyword. So what you found doesn't > really make sense. But it's also not relevant, since Empty > is not applicable to Err.Number. (Err.Number is a property > of the Err object, so it can't be an uninitialized variable.) > Just treat Err.Number as a numeric value and you'll be fine. > sense (this could be mostly due to my ignorance of VBScript). I was trying to see the contents of this property via: MsgBox "Current Error Number: " & CStr(Err.Number) Which was printing, "Current Error Number: ". Notice that lack of a number. Since this is a numerical value field, and can't be uninitialized, why would I see nothing when doing this? Just to make sure I was using the CStr function correctly, I did this: anInt = 99 MsgBox "An Int: " & CStr(anInt) Which appropriately printed, "An Int: 99." So, what's going on? Andy |
My System Specs![]() |
| | #7 (permalink) |
| | Re: What value should Err.Number be if there's no error > Ok, I tried the comparison to Empty because nothing else was making sense (this could be mostly due to my ignorance of VBScript). I was trying to see the contents of this property via: MsgBox "Current Error Number: " & CStr(Err.Number) Quote: > prints 0 for me. |
My System Specs![]() |
| | #8 (permalink) |
| | Re: What value should Err.Number be if there's no error On Oct 9, 3:02*pm, "mayayana" <mayaXXy...@xxxxxx> wrote: Quote: > Ok, I tried the comparison to Empty because nothing else was making > sense (this could be mostly due to my ignorance of VBScript). *I was > trying to see the contents of this property via: > > MsgBox "Current Error Number: " & CStr(Err.Number) > > > > * I don't know what the trouble might be there. It > prints 0 for me. keyboard and the chair. As I mentioned before, I'm a complete VBScript neophyte and it showed on this one. The problem was that I was redefining the err object, unwittingly. I didn't know that VBScript isn't case sensitive (all other languages I've written in thus far are) and I had this statement at the beginning of my script: Dim err This accounts for why I was getting "empty" variables instead of numbers, etc. Thanks for the help, Andy |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Help with windows vista mail, Socket Error: 10053, Error Number: 0x800CCC0F | Vista mail | |||
| no,socket Error: 11003. Error Number: 0x800CC0D cant i send email name is correctly | Vista mail | |||
| Socket Error: 10060, Error Number: 0x800CCC0E for VALID POP Server | Vista mail | |||
| Canot post to newsgroups Socket Error: 10053, Error Number: 0x800CCC0F | Vista mail | |||
| Canot post to newsgroups Socket Error: 10053, Error Number: 0x800CCC0F | Vista General | |||