PC Review


Reply
Thread Tools Rate Thread

How can I detect "nothing"?

 
 
plh
Guest
Posts: n/a
 
      9th Nov 2006
This takes a little explaining, please bear with me:
As part of a data mining project I have Excel (2003) VBA code that builds a list
out of a user defined variable type:

Type OpRec
.........
........
........[List of variable eliminated to save space]
End Type

Type SORec
strSOSfx As String
strPItem As String
OpRecord() As OpRec
End Type
Dim sO() As SORec

Because a few of the lines in the file this reads result from erroneous or
canceled shop orders, when the process reaches those lines, I try to skip over
them:

If (UBound(sO(i).OpRecord) <> 0) Then
This works OK for many but a few end up with "Subscript out of range". At such
times watches tell me that sO(i).OpRecord = Nothing.

I tried
If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> Nothing) Then
And got "Invalid use of Object"

I tried
Dim varNothing
Set varNothing = Nothing
If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> varNothing) Then
And got "Type Mismatch"

I tried
If (UBound(sO(i).OpRecord) <> 0) And Not IsNull(sO(i).OpRecord) Then
but got the message "Only user defined types defined in public object modules
can be coerced to or from a variant passed to late-bound functions"

This last one goes over my head. How do I set up a public object module (what
sources of info can I you recommend) and even if I do that, will it work? Or is
there a simpler way?
(There are many thousands of lines in the input file, so manual editing is not
an option!)
Thank You,
-plh


--
I keep hitting "Esc" -- but I'm still here!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      9th Nov 2006
I have not read your entire post but to detect nothing you need the word
is... Try this as an example...

sub Test
dim wbk as workbook
msgbox wbk is nothing
set wbk = thisworkbook
msgbox wbk is nothing
end sub

--
HTH...

Jim Thomlinson


"plh" wrote:

> This takes a little explaining, please bear with me:
> As part of a data mining project I have Excel (2003) VBA code that builds a list
> out of a user defined variable type:
>
> Type OpRec
> .........
> ........
> ........
>[List of variable eliminated to save space]
> End Type
>
> Type SORec
> strSOSfx As String
> strPItem As String
> OpRecord() As OpRec
> End Type
> Dim sO() As SORec
>
> Because a few of the lines in the file this reads result from erroneous or
> canceled shop orders, when the process reaches those lines, I try to skip over
> them:
>
> If (UBound(sO(i).OpRecord) <> 0) Then
> This works OK for many but a few end up with "Subscript out of range". At such
> times watches tell me that sO(i).OpRecord = Nothing.
>
> I tried
> If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> Nothing) Then
> And got "Invalid use of Object"
>
> I tried
> Dim varNothing
> Set varNothing = Nothing
> If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> varNothing) Then
> And got "Type Mismatch"
>
> I tried
> If (UBound(sO(i).OpRecord) <> 0) And Not IsNull(sO(i).OpRecord) Then
> but got the message "Only user defined types defined in public object modules
> can be coerced to or from a variant passed to late-bound functions"
>
> This last one goes over my head. How do I set up a public object module (what
> sources of info can I you recommend) and even if I do that, will it work? Or is
> there a simpler way?
> (There are many thousands of lines in the input file, so manual editing is not
> an option!)
> Thank You,
> -plh
>
>
> --
> I keep hitting "Esc" -- but I'm still here!
>

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      9th Nov 2006
I am uncertain about what your code does, but maybe...
If Not sO(i).OpRecord is Nothing Then
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"plh" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
This takes a little explaining, please bear with me:
As part of a data mining project I have Excel (2003) VBA code that builds a list
out of a user defined variable type:
Type OpRec
.........
........
........[List of variable eliminated to save space]
End Type
Type SORec
strSOSfx As String
strPItem As String
OpRecord() As OpRec
End Type
Dim sO() As SORec

Because a few of the lines in the file this reads result from erroneous or
canceled shop orders, when the process reaches those lines, I try to skip over
them:
If (UBound(sO(i).OpRecord) <> 0) Then
This works OK for many but a few end up with "Subscript out of range". At such
times watches tell me that sO(i).OpRecord = Nothing.
I tried
If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> Nothing) Then
And got "Invalid use of Object"
I tried
Dim varNothing
Set varNothing = Nothing
If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> varNothing) Then
And got "Type Mismatch"
I tried
If (UBound(sO(i).OpRecord) <> 0) And Not IsNull(sO(i).OpRecord) Then
but got the message "Only user defined types defined in public object modules
can be coerced to or from a variant passed to late-bound functions"
This last one goes over my head. How do I set up a public object module (what
sources of info can I you recommend) and even if I do that, will it work? Or is
there a simpler way?
(There are many thousands of lines in the input file, so manual editing is not
an option!)
Thank You,
-plh
--
I keep hitting "Esc" -- but I'm still here!
 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      9th Nov 2006
To test an object for Nothing, use the Is comparison operator. E.g.,

If Obj Is Nothing Then

or

If Not Obj Is Nothing Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)


"plh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This takes a little explaining, please bear with me:
> As part of a data mining project I have Excel (2003) VBA code that builds
> a list
> out of a user defined variable type:
>
> Type OpRec
> ........
> .......
> .......
>[List of variable eliminated to save space]
> End Type
>
> Type SORec
> strSOSfx As String
> strPItem As String
> OpRecord() As OpRec
> End Type
> Dim sO() As SORec
>
> Because a few of the lines in the file this reads result from erroneous or
> canceled shop orders, when the process reaches those lines, I try to skip
> over
> them:
>
> If (UBound(sO(i).OpRecord) <> 0) Then
> This works OK for many but a few end up with "Subscript out of range". At
> such
> times watches tell me that sO(i).OpRecord = Nothing.
>
> I tried
> If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> Nothing) Then
> And got "Invalid use of Object"
>
> I tried
> Dim varNothing
> Set varNothing = Nothing
> If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> varNothing) Then
> And got "Type Mismatch"
>
> I tried
> If (UBound(sO(i).OpRecord) <> 0) And Not IsNull(sO(i).OpRecord) Then
> but got the message "Only user defined types defined in public object
> modules
> can be coerced to or from a variant passed to late-bound functions"
>
> This last one goes over my head. How do I set up a public object module
> (what
> sources of info can I you recommend) and even if I do that, will it work?
> Or is
> there a simpler way?
> (There are many thousands of lines in the input file, so manual editing is
> not
> an option!)
> Thank You,
> -plh
>
>
> --
> I keep hitting "Esc" -- but I'm still here!



 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      9th Nov 2006
Seems to be much ado about Nothing! lol

"plh" wrote:

> This takes a little explaining, please bear with me:
> As part of a data mining project I have Excel (2003) VBA code that builds a list
> out of a user defined variable type:
>
> Type OpRec
> .........
> ........
> ........
>[List of variable eliminated to save space]
> End Type
>
> Type SORec
> strSOSfx As String
> strPItem As String
> OpRecord() As OpRec
> End Type
> Dim sO() As SORec
>
> Because a few of the lines in the file this reads result from erroneous or
> canceled shop orders, when the process reaches those lines, I try to skip over
> them:
>
> If (UBound(sO(i).OpRecord) <> 0) Then
> This works OK for many but a few end up with "Subscript out of range". At such
> times watches tell me that sO(i).OpRecord = Nothing.
>
> I tried
> If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> Nothing) Then
> And got "Invalid use of Object"
>
> I tried
> Dim varNothing
> Set varNothing = Nothing
> If (UBound(sO(i).OpRecord) <> 0) And (sO(i).OpRecord <> varNothing) Then
> And got "Type Mismatch"
>
> I tried
> If (UBound(sO(i).OpRecord) <> 0) And Not IsNull(sO(i).OpRecord) Then
> but got the message "Only user defined types defined in public object modules
> can be coerced to or from a variant passed to late-bound functions"
>
> This last one goes over my head. How do I set up a public object module (what
> sources of info can I you recommend) and even if I do that, will it work? Or is
> there a simpler way?
> (There are many thousands of lines in the input file, so manual editing is not
> an option!)
> Thank You,
> -plh
>
>
> --
> I keep hitting "Esc" -- but I'm still here!
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect if I use "AES" or "TKIP" as encryption method for "WPA-PSK"? Client or AP requirement? Kevin McNeal Windows XP Networking 2 27th Feb 2009 10:30 AM
Disabling device type from "auto detect" to "none" has no effect onslave drives kimiraikkonen Windows XP General 1 14th Jan 2008 12:29 PM
"detect when printer has finished printing" +"ms access" =?Utf-8?B?TG91?= Microsoft Access VBA Modules 1 10th May 2006 12:41 PM
How to detect a "RadioButton" server control 's "Checked" property on the client side? bredal Jensen Microsoft ASP .NET 0 26th Apr 2004 01:09 PM
"Detect and Repair" causes Print Layout View "lines" spectralUV Microsoft Word New Users 2 13th Feb 2004 11:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:54 PM.