VB用户定义类型未定义
OptionExplicitDimpstrMsgAsCDO.MessageDimpstrConfAsCDO.ConfigurationDimpstrFldsAsADODB...
Option Explicit
Dim pstrMsg As CDO.Message
Dim pstrConf As CDO.Configuration
Dim pstrFlds As ADODB.Fields
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请输入邮箱内容", 52, ""
ElseIf Text2.Text = "" Then
MsgBox "请输入发信邮箱", 52, ""
ElseIf Text3.Text = "" Then
MsgBox "请输入收信邮箱", 52, ""
ElseIf Text4.Text = "" Then
MsgBox "请输入SMTP服务器", 52, ""
ElseIf Text5.Text = "" Then
MsgBox "请输入邮箱主题", 52, ""
Else
MsgBox "邮件正在发送,请稍后......", 0, ""
End If
Set pstrMsg = New CDO.Message
Set pstrConf = New CDO.Configuration
Set pstrFlds = pstrConf.Fields
With pstrFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
With pstrMsg
Set .Configuration = pstrConf
.to = Text3
.Form = Text2
.subject = Text5
.HTMLbody = Text1
.send
End With
Set pstrMsg = Nothing
Set pstrConf = Nothing
Set pstrFlds = Nothing
End Sub
编译时显示 用户定义类型未定义
如何解决(VB小白 勿喷)谢谢! 展开
Dim pstrMsg As CDO.Message
Dim pstrConf As CDO.Configuration
Dim pstrFlds As ADODB.Fields
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请输入邮箱内容", 52, ""
ElseIf Text2.Text = "" Then
MsgBox "请输入发信邮箱", 52, ""
ElseIf Text3.Text = "" Then
MsgBox "请输入收信邮箱", 52, ""
ElseIf Text4.Text = "" Then
MsgBox "请输入SMTP服务器", 52, ""
ElseIf Text5.Text = "" Then
MsgBox "请输入邮箱主题", 52, ""
Else
MsgBox "邮件正在发送,请稍后......", 0, ""
End If
Set pstrMsg = New CDO.Message
Set pstrConf = New CDO.Configuration
Set pstrFlds = pstrConf.Fields
With pstrFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
With pstrMsg
Set .Configuration = pstrConf
.to = Text3
.Form = Text2
.subject = Text5
.HTMLbody = Text1
.send
End With
Set pstrMsg = Nothing
Set pstrConf = Nothing
Set pstrFlds = Nothing
End Sub
编译时显示 用户定义类型未定义
如何解决(VB小白 勿喷)谢谢! 展开
展开全部
1、需要定义的类型不存在,如:dim a as xx,而xx是没定义的(可能xx写错了),需要先定义xx类型。
2、工具:vb6
3、用户定义类型未定义错误分三类:
a)写错了默认变量类型名,如:dim a as intege,改成dim a as integer即可。
b)写错了自定义变量类型名,如自定义变量a1,写成了al,改正成a1即可。
c)定义了某种引用类型的变量类型,而未引用该对象,如:
dim conn as ADODB.Connection,
而未在工程中引用Microsoft ActiveX Data Objects 2.5 Library,工程中引ADO即可。
4、注意:引用必须是定义类型相应的对象,引用错误是无效的。
展开全部
正确的定义:
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
你的定义:
Private Sub Text1_MouseUp(Button As lnteger, Shift As Integer, X As Single, Y As Single)
你把integer给打成了lnteger。
(i和l不是同一个字母,大写体现不出效果,视觉上一样)
没有lnteger类型,所以出错!
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
你的定义:
Private Sub Text1_MouseUp(Button As lnteger, Shift As Integer, X As Single, Y As Single)
你把integer给打成了lnteger。
(i和l不是同一个字母,大写体现不出效果,视觉上一样)
没有lnteger类型,所以出错!
追问
大哥,你可不可以看一下,我没写这段。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你电脑里没有CDO.Message、CDO.Configuration、ADODB.Fields吧,就是他们的问题,但我不知怎么加
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-07-10
展开全部
是否引用了 cdosys.dll ,即Microsoft CDO for Windows 2000 Library
更多追问追答
追问
在哪看是否引用?
追答
打开vb的工程菜单,点引用,在对话框中钩选Microsoft CDO for Windows 2000 Library ,然后确定
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询