Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Simple question about 'vbCrLf' is not declared

Reply
Thread Tools

Re: Simple question about 'vbCrLf' is not declared

 
 
Patrice
Guest
Posts: n/a
 
      09-21-2004
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:6E93BEC3-4AA1-4560-B200-...
> 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
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      09-21-2004
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:6E93BEC3-4AA1-4560-B200-...
> > 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
> >

>
>
>

 
Reply With Quote
 
 
 
 
sanjeevsai sanjeevsai is offline
Junior Member
Join Date: May 2009
Posts: 2
 
      07-09-2009
Add the following namespace

Imports Microsoft.VisualBasic
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
declared or not declared ? JohnZing ASP .Net 3 02-05-2006 08:38 PM
Re: Simple question about 'vbCrLf' is not declared Karl Seguin ASP .Net 5 09-21-2004 05:34 PM
Re: Simple question about 'vbCrLf' is not declared GrantMagic ASP .Net 0 09-21-2004 04:32 PM
Re: Simple question about 'vbCrLf' is not declared Hermit Dave ASP .Net 0 09-21-2004 04:30 PM
Simple question about 'vbCrLf' is not declared =?Utf-8?B?Sm9l?= ASP .Net 0 09-21-2004 04:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57