Re: Simple question about 'vbCrLf' is not declared

Discussion in 'ASP .Net' started by Patrice, Sep 21, 2004.

  1. Patrice

    Patrice Guest

    Try ControlChars.vbCrLf instead of just vbCrLf.

    You are using VB.NET. The Microsoft.VisualBasic namespace is likely
    available (unless you changed the project default).

    Patrice

    --

    "Joe" <> a écrit dans le message de
    news:...
    > Hi,
    >
    > I have a simple form that does nothing but emails the whatever user

    entered
    > in the form fields. The form is working fine and email sent. The problem

    I
    > am having is in te string that forms the body of the email. I just want to
    > insert line breaks using vbCrLf, but when I do that I get an error saying,
    >
    > Compiler Error Message: BC30451: Name 'vbCrLf' is not declared.
    >
    >
    > The lins that gets highlighted is
    >
    > objMM.Body = "First Name: " & txtFirstName.Text & vbCrLf & vbCrLf & "Last
    > Name: " & _
    >
    > To see what I am doing, I have pasted to the code from the code behind

    file.
    > As you can see I am using VB and C#. I would appreciate if you can give

    me
    > some idea as why vbCrLf is not working.
    >
    > Thanks in advance
    >
    > Joe
    >
    >
    >
    > Option Explicit On
    > Option Strict On
    >
    > Imports System
    > Imports System.IO
    > Imports System.Web.UI.WebControls
    > Imports System.Data
    > Imports System.Data.OleDb
    > Imports System.Web.Mail
    >
    >
    > Public Class sendForm : Inherits System.Web.UI.Page
    >
    > Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtLastName As System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtCompany As System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtTitle As System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtPhone As System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtEmail As System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtReferrer As System.Web.UI.WebControls.TextBox
    > Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
    >
    > 'Public Const microsoft.visualbasic.Constants.vbCrLf as String =
    > Microsoft.VisualBasic.ControlChars.vbCrLf
    >
    > Sub Submit(ByVal sender As System.Object, ByVal e As System.EventArgs)
    >
    > Dim objMM as New MailMessage()
    > objMM.To = ""
    > objMM.From = ""
    > objMM.BodyFormat = MailFormat.Html
    > objMM.Priority = MailPriority.Normal
    > objMM.Subject = "Form details"
    >
    > 'Set the body
    > objMM.Body = "First Name: " & txtFirstName.Text & vbCrLf & vbCrLf &
    > "Last Name: " & _
    > txtLastName.Text & vbCrLf & vbCrLf & "Company: " &
    > txtCompany.Text & vbCrLf & vbCrLf & _
    > "Title: " & txtTitle.Text & vbCrLf & vbCrLf & "Phone: " &
    > txtPhone.Text & vbCrLf & vbCrLf & _
    > "Email: " & txtEmail.Text & vbCrLf & vbCrLf & "Referrer: " &
    > txtReferrer.Text & vbCrLf & vbCrLf & _
    > "Timestamp: " & DateTime.Now() & vbCrLf & vbCrLf & "IP address: " &
    > Request.UserHostAddress()
    >
    > SmtpMail.SmtpServer = ""
    > SmtpMail.Send(objMM)
    > End Sub
    >
    > End Class
    >
     
    Patrice, Sep 21, 2004
    #1
    1. Advertising

  2. I used ControlChars.vbCrLf and now getting error

    Compiler Error Message: BC30451: Name 'ControlChars' is not declared.

    How do I include the Microsoft.VisualBasic namespace?

    Joe



    "Patrice" wrote:

    > Try ControlChars.vbCrLf instead of just vbCrLf.
    >
    > You are using VB.NET. The Microsoft.VisualBasic namespace is likely
    > available (unless you changed the project default).
    >
    > Patrice
    >
    > --
    >
    > "Joe" <> a écrit dans le message de
    > news:...
    > > Hi,
    > >
    > > I have a simple form that does nothing but emails the whatever user

    > entered
    > > in the form fields. The form is working fine and email sent. The problem

    > I
    > > am having is in te string that forms the body of the email. I just want to
    > > insert line breaks using vbCrLf, but when I do that I get an error saying,
    > >
    > > Compiler Error Message: BC30451: Name 'vbCrLf' is not declared.
    > >
    > >
    > > The lins that gets highlighted is
    > >
    > > objMM.Body = "First Name: " & txtFirstName.Text & vbCrLf & vbCrLf & "Last
    > > Name: " & _
    > >
    > > To see what I am doing, I have pasted to the code from the code behind

    > file.
    > > As you can see I am using VB and C#. I would appreciate if you can give

    > me
    > > some idea as why vbCrLf is not working.
    > >
    > > Thanks in advance
    > >
    > > Joe
    > >
    > >
    > >
    > > Option Explicit On
    > > Option Strict On
    > >
    > > Imports System
    > > Imports System.IO
    > > Imports System.Web.UI.WebControls
    > > Imports System.Data
    > > Imports System.Data.OleDb
    > > Imports System.Web.Mail
    > >
    > >
    > > Public Class sendForm : Inherits System.Web.UI.Page
    > >
    > > Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox
    > > Protected WithEvents txtLastName As System.Web.UI.WebControls.TextBox
    > > Protected WithEvents txtCompany As System.Web.UI.WebControls.TextBox
    > > Protected WithEvents txtTitle As System.Web.UI.WebControls.TextBox
    > > Protected WithEvents txtPhone As System.Web.UI.WebControls.TextBox
    > > Protected WithEvents txtEmail As System.Web.UI.WebControls.TextBox
    > > Protected WithEvents txtReferrer As System.Web.UI.WebControls.TextBox
    > > Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
    > >
    > > 'Public Const microsoft.visualbasic.Constants.vbCrLf as String =
    > > Microsoft.VisualBasic.ControlChars.vbCrLf
    > >
    > > Sub Submit(ByVal sender As System.Object, ByVal e As System.EventArgs)
    > >
    > > Dim objMM as New MailMessage()
    > > objMM.To = ""
    > > objMM.From = ""
    > > objMM.BodyFormat = MailFormat.Html
    > > objMM.Priority = MailPriority.Normal
    > > objMM.Subject = "Form details"
    > >
    > > 'Set the body
    > > objMM.Body = "First Name: " & txtFirstName.Text & vbCrLf & vbCrLf &
    > > "Last Name: " & _
    > > txtLastName.Text & vbCrLf & vbCrLf & "Company: " &
    > > txtCompany.Text & vbCrLf & vbCrLf & _
    > > "Title: " & txtTitle.Text & vbCrLf & vbCrLf & "Phone: " &
    > > txtPhone.Text & vbCrLf & vbCrLf & _
    > > "Email: " & txtEmail.Text & vbCrLf & vbCrLf & "Referrer: " &
    > > txtReferrer.Text & vbCrLf & vbCrLf & _
    > > "Timestamp: " & DateTime.Now() & vbCrLf & vbCrLf & "IP address: " &
    > > Request.UserHostAddress()
    > >
    > > SmtpMail.SmtpServer = ""
    > > SmtpMail.Send(objMM)
    > > End Sub
    > >
    > > End Class
    > >

    >
    >
    >
     
    =?Utf-8?B?Sm9l?=, Sep 21, 2004
    #2
    1. Advertising

  3. Patrice

    sanjeevsai

    Joined:
    May 28, 2009
    Messages:
    2
    Add the following namespace

    Imports Microsoft.VisualBasic
     
    sanjeevsai, Jul 9, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hermit Dave
    Replies:
    0
    Views:
    411
    Hermit Dave
    Sep 21, 2004
  2. GrantMagic
    Replies:
    0
    Views:
    417
    GrantMagic
    Sep 21, 2004
  3. Karl Seguin
    Replies:
    5
    Views:
    1,958
    i. Wiin
    Sep 21, 2004
  4. =?Utf-8?B?Sm9l?=

    Simple question about 'vbCrLf' is not declared

    =?Utf-8?B?Sm9l?=, Sep 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    398
    =?Utf-8?B?Sm9l?=
    Sep 21, 2004
  5. JohnZing

    declared or not declared ?

    JohnZing, Feb 5, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,619
    Jon Paal
    Feb 5, 2006
Loading...

Share This Page