| Author |
Object Required when using set
|
|
| Luis Feliz 2005-02-08, 4:01 am |
| Guys -
I keep getting "object required" when running this code.
All the variables are defined, cant understand why the set command would
fail.
Thanks in advance,
Luis Feliz
-------------------------- Start Code ---------------------
'This is Form1
Dim MyMsgs as MsgArr
Private Sub Command2_Click()
GetMessages MyMsgs
End Sub
---------------------------------------------
'This is on module1.bas
Option Explicit
'Definitions
Type EmailMsg
sTo As String
StoName As String
sFrom As String
sFromName As String
sSubject As String
sMessage As String
sHeaders As String
sSource As String
End Type
Public Type MsgArr
Email(0 To 100) As EmailMsg
Count As Integer
End Type
Dim Msgs As MsgArr
Public Sub GetMessages(ByRef em As MsgArr)
Set Msgs = em <--------Error Happens here
(Object Required)
msgs.count = 0
End Sub
| |
| Greg Teets 2005-02-08, 4:01 am |
| On Tue, 08 Feb 2005 05:30:45 GMT, "Luis Feliz" <luisfeliz@verizon.net>
wrote:
>Guys -
>
>I keep getting "object required" when running this code.
>
>All the variables are defined, cant understand why the set command would
>fail.
>
>Thanks in advance,
>
>Luis Feliz
>
>-------------------------- Start Code ---------------------
>'This is Form1
>Dim MyMsgs as MsgArr
>
>Private Sub Command2_Click()
>
> GetMessages MyMsgs
>
>End Sub
>
>---------------------------------------------
>
>'This is on module1.bas
>
>Option Explicit
>
>'Definitions
>
>Type EmailMsg
> sTo As String
> StoName As String
> sFrom As String
> sFromName As String
> sSubject As String
> sMessage As String
> sHeaders As String
> sSource As String
>End Type
>
>Public Type MsgArr
> Email(0 To 100) As EmailMsg
> Count As Integer
>End Type
>
>Dim Msgs As MsgArr
>
>Public Sub GetMessages(ByRef em As MsgArr)
>
> Set Msgs = em <--------Error Happens here
>(Object Required)
> msgs.count = 0
>
>End Sub
>
You forgot to declare your variable 'em'.
Set is only used with objects. Otherwise, you can just use "=".
Greg Teets
Cincinnati Ohio USA
| |
| Jeff Johnson [MVP:VB] 2005-02-08, 4:01 am |
|
"Luis Feliz" <luisfeliz@verizon.net> wrote in message
news:98YNd.10979$ya6.5014@trndny01...
> I keep getting "object required" when running this code.
> Dim Msgs As MsgArr
>
> Public Sub GetMessages(ByRef em As MsgArr)
>
> Set Msgs = em <--------Error Happens here
> (Object Required)
Arrays aren't objects; you can't use Set on them.
| |
| Bob O`Bob 2005-02-09, 9:00 pm |
| Luis Feliz wrote:
> Guys -
>
> I keep getting "object required" when running this code.
>
> All the variables are defined, cant understand why the set command would
> fail.
>
> Thanks in advance,
>
> Luis Feliz
>
> -------------------------- Start Code ---------------------
> 'This is Form1
> Dim MyMsgs as MsgArr
>
> Private Sub Command2_Click()
>
> GetMessages MyMsgs
>
> End Sub
>
> ---------------------------------------------
>
> 'This is on module1.bas
>
> Option Explicit
>
> 'Definitions
>
> Type EmailMsg
> sTo As String
> StoName As String
> sFrom As String
> sFromName As String
> sSubject As String
> sMessage As String
> sHeaders As String
> sSource As String
> End Type
>
> Public Type MsgArr
> Email(0 To 100) As EmailMsg
> Count As Integer
> End Type
>
> Dim Msgs As MsgArr
>
> Public Sub GetMessages(ByRef em As MsgArr)
>
> Set Msgs = em <--------Error Happens here
> (Object Required)
> msgs.count = 0
>
> End Sub
>
>
I'm not sure I follow quite what you're trying to do,
but it looks like maybe what you really want is LSet.
Bob
| |
|
| You don't need to use Set to with a UDT (Type ... End Type)
Luis Feliz wrote:
> Guys -
>
> I keep getting "object required" when running this code.
>
> All the variables are defined, cant understand why the set command would
> fail.
>
> Thanks in advance,
>
> Luis Feliz
>
> -------------------------- Start Code ---------------------
> 'This is Form1
> Dim MyMsgs as MsgArr
>
> Private Sub Command2_Click()
>
> GetMessages MyMsgs
>
> End Sub
>
> ---------------------------------------------
>
> 'This is on module1.bas
>
> Option Explicit
>
> 'Definitions
>
> Type EmailMsg
> sTo As String
> StoName As String
> sFrom As String
> sFromName As String
> sSubject As String
> sMessage As String
> sHeaders As String
> sSource As String
> End Type
>
> Public Type MsgArr
> Email(0 To 100) As EmailMsg
> Count As Integer
> End Type
>
> Dim Msgs As MsgArr
>
> Public Sub GetMessages(ByRef em As MsgArr)
>
> Set Msgs = em <--------Error Happens here
> (Object Required)
> msgs.count = 0
>
> End Sub
>
>
|
|
|
|