User-Defined Variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

Alright, I have the dumbest question. I want to do something, but I don't
know what it's called. So I can't look up an example. This is such a moron
thing to do, but I'm hoping someone can help me out.

I created a user defined variable, and what I want to add is a function for
the type that I can use to determine if all the sub variables are empty.

Here's what I mean:
Public Type newData
firstName as String
lastName as String
orderNum as String
End Type

Then, in my Access 97 code, I just want to write:
If newData.isEmpty() Then
msgbox "No data entered."
End If
Which would return true if all the string are zero length ("").

I can't remember what this is called. I think it's a struct in C++, but I'm
not even 100% sure. Does VB have an equivalent? I'm having a complete
brainfart here. =)

Thanks for any help.

Jay
 
Jay said:
Hi all,

Alright, I have the dumbest question. I want to do something, but I don't
know what it's called. So I can't look up an example. This is such a
moron
thing to do, but I'm hoping someone can help me out.

I created a user defined variable, and what I want to add is a function
for
the type that I can use to determine if all the sub variables are empty.

Here's what I mean:
Public Type newData
firstName as String
lastName as String
orderNum as String
End Type

Then, in my Access 97 code, I just want to write:
If newData.isEmpty() Then
msgbox "No data entered."
End If
Which would return true if all the string are zero length ("").

I can't remember what this is called. I think it's a struct in C++, but
I'm
not even 100% sure. Does VB have an equivalent? I'm having a complete
brainfart here. =)

Thanks for any help.

Jay


Obviously we can't advise on the suitability of a user-defined type in your
particular application because we don't know the details. Anyway, assuming
you go down this route, you would have to pass the newData variable to a
function such as the one below.
User-defined types can be useful, but using Access you can also develop
class modules which let you do more advanced stuff, but if it helps here is
a start with the user-defined type:

Public Function newDataIsEmpty(nd As newData) As Boolean

Dim bln As Boolean

With nd
If Len(.firstName) > 0 Then bln = True
If Len(.lastName) > 0 Then bln = True
If Len(.orderNum) > 0 Then bln = True
End With

newDataIsEmpty = Not bln

End Function
 
I think Class Module is actually what I'm looking for, but I couldn't
remember the name (very daft, I admit). Thanks though. Now I know what to
look up.

Jay
 
Back
Top