Public Type vs. Public variable() as Double 
Author Message
 Public Type vs. Public variable() as Double

I am trying to change from using several different arrays
holding pieces of information
e.g. (in Module1)
Public name() as String
Public height() as Integer
Public width() as Double
Public depth() as Long

to a Data Type containing those members
e.g. (also in Module1)
Public Type UnitDims
    typename as String
    typeheight as Integer
    typewidth as Double
    typedepth as Long
End Type
Public mydims() as UnitDims

(NOTE: Integer, double and long types are used only for
example purposes)

However, when I change what was working code in FormMain:
  On Error Resume Next
  x = Ubound(height)     'Has Array be initialized?
  errchk = IIf(Err=0,True,False)
  If errchk Then
      For z = 0 to Ubound(height)
          If height(z) > maxheight then
             .....
          End If
      Next x
  End If

and try to change it to:
  On Error Resume Next
  x = Ubound(mydims)     'Has Array be initialized?
  errchk = IIf(Err=0,True,False)
  If errchk Then
      For z = 0 to Ubound(mydims)
          If mydims.typeheight(z) > maxheight then
             .....
          End If
      Next x
  End If

I get "Compile error - invalid qualifier" and the mydims
(at the "If mydims.typeheight (z)..." line)is highlighted.
I've tried using Module1.mydims.typeheight(z), but I
receive the same error?

Any suggestions?

Thanks,
Craig

I have tried



Mon, 26 Jul 2004 08:23:00 GMT  
 Public Type vs. Public variable() as Double
Hi,

I would suggest you change the line to:
          If mydims(z).typeheight
I'm sure you will understand why.

John..........

Quote:

> I am trying to change from using several different arrays
> holding pieces of information
> e.g. (in Module1)
> Public name() as String
> Public height() as Integer
> Public width() as Double
> Public depth() as Long

> to a Data Type containing those members
> e.g. (also in Module1)
> Public Type UnitDims
>     typename as String
>     typeheight as Integer
>     typewidth as Double
>     typedepth as Long
> End Type
> Public mydims() as UnitDims

> (NOTE: Integer, double and long types are used only for
> example purposes)

> However, when I change what was working code in FormMain:
>   On Error Resume Next
>   x = Ubound(height)     'Has Array be initialized?
>   errchk = IIf(Err=0,True,False)
>   If errchk Then
>       For z = 0 to Ubound(height)
>           If height(z) > maxheight then
>              .....
>           End If
>       Next x
>   End If

> and try to change it to:
>   On Error Resume Next
>   x = Ubound(mydims)     'Has Array be initialized?
>   errchk = IIf(Err=0,True,False)
>   If errchk Then
>       For z = 0 to Ubound(mydims)
>           If mydims.typeheight(z) > maxheight then
>              .....
>           End If
>       Next x
>   End If

> I get "Compile error - invalid qualifier" and the mydims
> (at the "If mydims.typeheight (z)..." line)is highlighted.
> I've tried using Module1.mydims.typeheight(z), but I
> receive the same error?

> Any suggestions?

> Thanks,
> Craig

> I have tried



Mon, 26 Jul 2004 08:32:27 GMT  
 Public Type vs. Public variable() as Double
Try
           If mydims(z).typeheight > maxheight then

Also, On Error Resume Next is not good practice for most purposes. Too
often it masks the actual error and otherwise muddles the code. An error
handler is a better choice.

HTH,

John Eikanger
Microsoft Visual Basic Developer Support

This posting is provided AS IS with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message


| Subject: Public Type vs. Public variable() as Double
| Date: Wed, 6 Feb 2002 16:23:00 -0800
| Lines: 57

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
| Thread-Index: AcGvbZlG1O4Ht5JjSDSsqOqPoDHntg==
| Newsgroups: microsoft.public.vb.syntax
| Path: cpmsftngxa07
| Xref: cpmsftngxa07 microsoft.public.vb.syntax:68820
| NNTP-Posting-Host: TKMSFTNGXA12 10.201.226.40
| X-Tomcat-NG: microsoft.public.vb.syntax
|
| I am trying to change from using several different arrays
| holding pieces of information
| e.g. (in Module1)
| Public name() as String
| Public height() as Integer
| Public width() as Double
| Public depth() as Long
|
| to a Data Type containing those members
| e.g. (also in Module1)
| Public Type UnitDims
|     typename as String
|     typeheight as Integer
|     typewidth as Double
|     typedepth as Long
| End Type
| Public mydims() as UnitDims
|
| (NOTE: Integer, double and long types are used only for
| example purposes)
|
| However, when I change what was working code in FormMain:
|   On Error Resume Next
|   x = Ubound(height)     'Has Array be initialized?
|   errchk = IIf(Err=0,True,False)
|   If errchk Then
|       For z = 0 to Ubound(height)
|           If height(z) > maxheight then
|              .....
|           End If
|       Next x
|   End If
|
| and try to change it to:
|   On Error Resume Next
|   x = Ubound(mydims)     'Has Array be initialized?
|   errchk = IIf(Err=0,True,False)
|   If errchk Then
|       For z = 0 to Ubound(mydims)
|           If mydims.typeheight(z) > maxheight then
|              .....
|           End If
|       Next x
|   End If
|
| I get "Compile error - invalid qualifier" and the mydims
| (at the "If mydims.typeheight (z)..." line)is highlighted.
| I've tried using Module1.mydims.typeheight(z), but I
| receive the same error?
|
| Any suggestions?
|
| Thanks,
| Craig
|
| I have tried
|
|



Mon, 26 Jul 2004 08:44:45 GMT  
 Public Type vs. Public variable() as Double
You are creating an array of mydims, not an array of elements in mydims. You
have to reference it the same way its declared ...

   If mydims(z).typeheight > maxheight then ...

--

Randy Birch
MVP Visual Basic

http://www.mvps.org/vbnet/

Please respond only to the newsgroups so all can benefit.


Quote:
> I am trying to change from using several different arrays
> holding pieces of information
> e.g. (in Module1)
> Public name() as String
> Public height() as Integer
> Public width() as Double
> Public depth() as Long

> to a Data Type containing those members
> e.g. (also in Module1)
> Public Type UnitDims
>     typename as String
>     typeheight as Integer
>     typewidth as Double
>     typedepth as Long
> End Type
> Public mydims() as UnitDims

> (NOTE: Integer, double and long types are used only for
> example purposes)

> However, when I change what was working code in FormMain:
>   On Error Resume Next
>   x = Ubound(height)     'Has Array be initialized?
>   errchk = IIf(Err=0,True,False)
>   If errchk Then
>       For z = 0 to Ubound(height)
>           If height(z) > maxheight then
>              .....
>           End If
>       Next x
>   End If

> and try to change it to:
>   On Error Resume Next
>   x = Ubound(mydims)     'Has Array be initialized?
>   errchk = IIf(Err=0,True,False)
>   If errchk Then
>       For z = 0 to Ubound(mydims)
>           If mydims.typeheight(z) > maxheight then
>              .....
>           End If
>       Next x
>   End If

> I get "Compile error - invalid qualifier" and the mydims
> (at the "If mydims.typeheight (z)..." line)is highlighted.
> I've tried using Module1.mydims.typeheight(z), but I
> receive the same error?

> Any suggestions?

> Thanks,
> Craig

> I have tried



Mon, 26 Jul 2004 10:40:49 GMT  
 Public Type vs. Public variable() as Double
How do you check if a table is dim or not?

the only way i know (to make it readable) is:

Dim LastIndex as Integer
Dim Table() as Integer

On Error Resume Next
LastIndex = UBound(Table)
If Err Then
    'Message box or Exit Sub (wich is not a better programming practice...)
End If
On Error Goto 0

Thanks
Zoury


Quote:
> Try
>            If mydims(z).typeheight > maxheight then

> Also, On Error Resume Next is not good practice for most purposes. Too
> often it masks the actual error and otherwise muddles the code. An error
> handler is a better choice.

> HTH,

> John Eikanger
> Microsoft Visual Basic Developer Support

> This posting is provided "AS IS" with no warranties, and confers no
rights.

> --------------------
> | Content-Class: urn:content-classes:message


> | Subject: Public Type vs. Public variable() as Double
> | Date: Wed, 6 Feb 2002 16:23:00 -0800
> | Lines: 57

> | MIME-Version: 1.0
> | Content-Type: text/plain;
> | charset="iso-8859-1"
> | Content-Transfer-Encoding: 7bit
> | X-Newsreader: Microsoft CDO for Windows 2000
> | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
> | Thread-Index: AcGvbZlG1O4Ht5JjSDSsqOqPoDHntg==
> | Newsgroups: microsoft.public.vb.syntax
> | Path: cpmsftngxa07
> | Xref: cpmsftngxa07 microsoft.public.vb.syntax:68820
> | NNTP-Posting-Host: TKMSFTNGXA12 10.201.226.40
> | X-Tomcat-NG: microsoft.public.vb.syntax
> |
> | I am trying to change from using several different arrays
> | holding pieces of information
> | e.g. (in Module1)
> | Public name() as String
> | Public height() as Integer
> | Public width() as Double
> | Public depth() as Long
> |
> | to a Data Type containing those members
> | e.g. (also in Module1)
> | Public Type UnitDims
> |     typename as String
> |     typeheight as Integer
> |     typewidth as Double
> |     typedepth as Long
> | End Type
> | Public mydims() as UnitDims
> |
> | (NOTE: Integer, double and long types are used only for
> | example purposes)
> |
> | However, when I change what was working code in FormMain:
> |   On Error Resume Next
> |   x = Ubound(height)     'Has Array be initialized?
> |   errchk = IIf(Err=0,True,False)
> |   If errchk Then
> |       For z = 0 to Ubound(height)
> |           If height(z) > maxheight then
> |              .....
> |           End If
> |       Next x
> |   End If
> |
> | and try to change it to:
> |   On Error Resume Next
> |   x = Ubound(mydims)     'Has Array be initialized?
> |   errchk = IIf(Err=0,True,False)
> |   If errchk Then
> |       For z = 0 to Ubound(mydims)
> |           If mydims.typeheight(z) > maxheight then
> |              .....
> |           End If
> |       Next x
> |   End If
> |
> | I get "Compile error - invalid qualifier" and the mydims
> | (at the "If mydims.typeheight (z)..." line)is highlighted.
> | I've tried using Module1.mydims.typeheight(z), but I
> | receive the same error?
> |
> | Any suggestions?
> |
> | Thanks,
> | Craig
> |
> | I have tried
> |
> |



Mon, 26 Jul 2004 22:46:40 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. public variables not public

2. Passing Public user-defined types via Public Functions

3. Public variable not acting public (VB 5.0)

4. Declaring variables as Static vs Private/Public -- XML

5. Property vs. Public Variable

6. Property Get vs Public Variable

7. Public variables vs. Forms remaining open

8. Public vs Private variables

9. Public Type Variable not Recognized in dynamic module

10. Use a public variable or use Private variable with Get and Set

11. Public Contact linked to a public journal entry

12. Appointment copy to Public Calender And Public Journal

 

 
Powered by phpBB® Forum Software