ERROR MESSAGE CITES DIFFERENT LINE FROM PROBLEM

  • Thread starter Thread starter dancer
  • Start date Start date
D

dancer

I get this message saying line 75 is the problem.
But when I take out " & StateOfInjury & " from a line much further down
(check out my code which follows),
the error goes away.

Anybody know why?


Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and 'System.Web.UI.WebControls.TextBox'.

Source File: c:\inetpub\wwwroot\liberty46.aspx Line: 75


Line 73:
Line 74:
Line 75: myMessage.Body = "<h2>Wheeler's Express Accident Report
Form</h2>" & vbCrLf _
Line 76: & " <p>" & vbCrLf _
Line 77: & "<html><body> <table width = ""750"" bgcolor=""#E9EDF4""
height=""25"" border=""1"" cellpadding=""3"" fontface=""Verdana""
Size=""2"">" & vbCrLf _



<%@ Page Language="VB" Debug = "true" ValidateRequest="false" %>

<%@ Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendMail_OnClick(Source As Object, E As EventArgs)


Dim TheEmpName As String = EmpName.text

Dim TheHomeNumber As String = HomeNumber.text

Dim TheDate As String = DateofAccident.Text


Dim TheNotifyDate As String = NotifyDate.Text

Dim TheTimeAM As String = am.Text

Dim TheTimePM As String = pm.Text

Dim TheTime As String

Dim Thedie As String = Die.SelectedItem.Text

Dim TheLostDays As String = LostDays.SelectedItem.Text

Dim TheStateOfInjury As String = StateOfInjury.Text

Dim TheStreet As String = street.text

Dim TheCity As String = city.text

Dim TheAddressState as String = AddressState.Text

Dim TheZip As String = Zip.text

Dim TheSSN As String = SSN.text

Dim TheSex As String = Sex.SelectedItem.Text

Dim TheJob As string = Job.Text

Dim ThePart As String = Part.Text


Dim TheNature As String = nature.Text

Dim TheNatureNew As String

Dim TheDescription As String = Description.Text

Dim TheInitial As String = Initial.SelectedItem.Text

Dim TheProvider As String = Provider.SelectedItem.Text

Dim TheAmitted As String = Admitted.SelectedItem.Text

Dim TheMed_provider as string = Med_Provider.Text

Dim TheOccur As String = Occur.SelectedItem.Text

Dim TheAccidentStreet As String = AccidentStreet.Text

Dim TheAccidentCity As String = AccidentCity.Text

dim TheAccidentState as String = AccidentState.Text

Dim TheAccidentZip as String = AccidentZip.Text

Dim TheOtherClaims as String = OtherClaims.SelectedItem.Text

Dim TheSafetyDevices as string = SafetyDevices.selectedItem.Text

Dim TheDevicesUtilized as string = DevicesUtilized.selectedItem.Text

Dim TheWitness as string = Witness.SelectedItem.Text

Dim TheComments as String = Comments.Text

Dim TheSubmitter As String = Submitter.Text

Dim TheToday As String = Today.Text

Dim myMessage As New MailMessage

Dim myMail As SmtpMail

Dim strEmail As String

Dim UserMessage As String


If TheTimeAm <> "" Then

TheTime = TheTimeAm & " AM"

ElseIf TheTimePM <> "" Then

TheTime = TheTimePM & " PM"

Else TheTime = ""

End If


If Page.IsValid() Then


Response.Write ("<font color=""red"">FORM HAS BEEN SENT TO
RIVERSIDE</font>")


myMessage.From = "(e-mail address removed)"

MyMessage.To = "(e-mail address removed)"

myMessage.Subject = "Accident Form from "

' This is the magic line. Without this the message will just appear

' as plain HTML and won't be rendered by the recipient's email client.

' It'd be as if they did "View Source" on a web page.

MyMessage.BodyFormat = MailFormat.Html



myMessage.Body = "<h2>Wheeler's Express Accident Report Form</h2>" & vbCrLf
_

& " <p>" & vbCrLf _

& "<html><body> <table width = ""750"" bgcolor=""#E9EDF4"" height=""25""
border=""1"" cellpadding=""3"" fontface=""Verdana"" Size=""2"">" & vbCrLf _

& "<td colspan=""3"" bgcolor=""maroon"" align=""center""> <font
face=""Verdana"" Size=""2"" color=""white""><b> BASIC CLAIM
FACTS</b></td></tr>" & vbCrLf _

& "<tr><td> Employee's Name: "& TheEmpName & "</td>" & vbCrLf _

& "<td> Home Phone Number: "& TheHomeNumber & "</td></tr>" & vbCrLf _

& "<tr><td> Date of Injury: " & TheDate & "<br>" & "</td>" & vbCrLf _

& "<td> Time of Injury: " & TheTime & "<br>" & "</td></tr>" & "</tr>" &
vbCrLf _

& "<tr><td> Date Employer Notified: " & TheNotifyDate & "</td>" & vbCrLf _

& "<td> Did Employee Die? " & Thedie & "</td><tr>" & vbCrLf _

& "<tr><td> Has the Injured Employee Lost Days From Work?" & TheLostDays &
"</td></tr>" & vbCrLf _

& "<tr><td> What State did Injury Occur? " & StateOfInjury & "</td></tr>" &
vbCrLf _

& "<tr> <td> Person submitting this form: " & "<br>" & theSubmitter &
"</td>" & vbCrLf _

& "<td> Date: " & Thetoday & vbCrLf _

& "</td><tr></table> </body>"

' Doesn't have to be local... just enter your

' SMTP server's name or ip address!

' myMail.SmtpServer = "smtp.wheelers.com"

myMail.SmtpServer = ""

myMail.Send(myMessage)

frmEmail.Visible = False

UserMessage = "Has Been Sent."


End If

End Sub



</script>

<html>

<head>

<title>ASP.NET Email (HTML Format) Sample</title>

</head>

<body>


<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Express Accident Report
Form</font></center></h3>



<form method="post" id="frmEmail" runat="server">




<%--____________________________________________________________________________--%>

<%--Section 1--%>

<tr><td colspan="3" bgcolor="maroon" align="center"> <font face="Verdana"
Size="2" color="white"><b> BASIC CLAIM FACTS</b></td></tr>


<td bgcolor="#E9EDF4" colspan ="2">


<font face="Verdana" Size="2">

Employee's Name: <asp:textbox id="EmpName" runat=server columns="45"/>

<asp:RequiredFieldValidator id="RequiredFiedlValidator1" runat="server"
Text="The Employee name field is required."

ControlToValidate="EmpName"></asp:RequiredFieldValidator>

</td>

<%---------------------------------------------------------------------------%>

<td align="right" valign="top" width="215">


<font face="Verdana" Size="2">Home Phone Number

<asp:TextBox id=HomeNumber runat="server"/>


</td></tr>

<%--____________________________________________________________________________--%>

<%--ROW 2--%>


<tr><td colspan="1" valign="center">

<font face="Verdana" Size="2">Date of Injury </font>

<asp:textbox id="DateofAccident" runat=server /></asp:textbox>

<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server"

Text="The Date field is required" ControlToValidate="Dateofaccident">

</asp:RequiredFieldValidator>

</td><td colspan="2"><font face="Verdana" Size="2">Time of Injury
<asp:textbox columns="6" id ="am" runat=server/>a.m.

<asp:textbox columns="6" id= "pm" runat = server/> p.m.</td>

</TD>

</tr>



<tr>

<td>

<font face="Verdana" Size="2">Date Employer Notified <asp:textbox
id="Notifydate" runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorNotify" runat="server"

Text="The Date field is required" ControlToValidate="NotifyDate">

</asp:RequiredFieldValidator>


</td>

<td colspan="2"> <font face="Verdana" Size="2"> Did employee die?
<asp:RadioButtonList id="Die" RepeatDirection="Horizontal" Runat=server>

<asp:ListItem><font face="Verdana" Size="2">Yes</asp:ListItem>

<asp:ListItem><font face="Verdana" Size="2">No</asp:ListItem>
</asp:RadioButtonList>

</td></tr>


<tr><td colspan="2"> <font face="Verdana" Size="2"> Has the Injured Employee
Lost Days From Work?

<asp:RadioButtonList id="LostDays" RepeatDirection="Horizontal"
Runat=server>

<asp:ListItem><font face="Verdana" Size="2">Yes</asp:ListItem>

<asp:ListItem><font face="Verdana" Size="2">No</asp:ListItem>
</asp:RadioButtonList>



</tr>

<tr><td colspan="3"><font face="Verdana" Size="2">What State did Injury
Occur? <asp:textbox id="StateOfInjury" runat=server/> </td></tr>

<%--SECTION3-----------------------------------------------------------------------------------%>

<tr><td colspan="3" bgcolor="maroon" align="center"> <font face="Verdana"
color="white" Size="2"><b> INJURED EMPLOYEE</b></td></tr>

<tr><td colspan="3"> <font face="Verdana" Size="2"> Home address Street
<asp:TextBox id="street" columns="90" runat=server/>

</td></tr>

<tr> <td> <font face="Verdana" Size="2"> City <asp:TextBox id="City"
columns="40" runat=server/>

</td> <td> <font face="Verdana" Size="2"> State <asp:TextBox
id="AddressState" columns="2" runat=server/>

</td> <td> <font face="Verdana" Size="2"> Zip <asp:TextBox id="Zip"
runat=server/>

</td></tr>

<tr><td> <font face="Verdana" Size="2">Date of Birth: <asp:textbox id=birth
columns="10" runat=server/>

</td><td><font face="Verdana" Size="2"> SSN:<asp:textbox id=SSN columns="11"
runat=server/>


</td><td><font face="Verdana" Size="2"> Check one<asp:RadioButtonList
id="Sex" RepeatDirection="Horizontal" runat="server">

<asp:ListItem><font face="Verdana" Size="2">Male</asp:ListItem>

<asp:ListItem><font face="Verdana" Size="2">Female</asp:ListItem>
</asp:RadioButtonList>

</td></tr><td colspan="1"><font face="Verdana" Size="2"> Marital Status
<asp:RadiobuttonList id=Marital RepeatDirection="Vertical"

runat=server>

<asp:ListItem> <font face="Verdana" Size="2"> Single </asp:ListItem>

<asp:ListItem><font face="Verdana" Size="2"> Married </asp:ListItem>

<asp:ListItem><font face="Verdana" Size="2"> Widowed </asp:ListItem>

<asp:ListItem><font face="Verdana" Size="2">
Divorced</asp:ListItem></asp:RadioButtonList>

</td><td colspan="2"><font face="Verdana" Size="2"> Phone Number where
Employee can be Contacted: <asp:TextBox id=contactnumber runat=server/>

</td></tr><tr><td colspan="3"> <font face="Verdana" Size="2"> Job
Description <Asp:TextBox id=Job columns="90" runat=server/>

</td></tr><tr><td colspan="2"> <font face="Verdana" Size="2"> Supervisor's
Name <Asp:TextBox id=Supervisor Columns = "40" runat=server/>

</td></tr>

<tr><td colspan="3" bgcolor="MAROON" align="center"> <font face="Verdana"
Size="2" COLOR="WHITE"><b> INJURY OR ILLNESS</b></td></tr>

</td></tr> <tr><td colspan="3"><font face="Verdana" Size="2"> Which part of
the Body Was Injured? (If leg, hand or arm, specify left or right. If
finger, specify which)

<asp:textbox id="part" columns = "40" runat = server/>

</td></tr> <tr><td colspan="3">

<font face="Verdana" Size="2"> What was the Nature Injury (e.g. Fracture,
Sprain, Laceration)?

<asp:textbox TextMode="MultiLine" Rows="2" columns= "85" id="nature"
runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorNature" runat="server"

Text="You must answer this question" ControlToValidate="nature">

</asp:RequiredFieldValidator>

</td></tr><tr><td colspan="3" valign="center">

<font face="Verdana" Size="2"> Injury/Illness Description:

<asp:textbox TextMode="MultiLine" Rows="2" columns= "65" id="Description"
runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorDescrip"
runat="server"

Text="You must answer this question" ControlToValidate="Description">

</asp:RequiredFieldValidator>

</td></tr><tr><td><font face="Verdana" Size="2"> Initial Medical Treatment:

<asp:RadioButtonList font-name="verdana" font-size="10 pt" id=Initial
runat="server">

<asp:ListItem>ER Treated & Released</asp:ListItem>

<asp:ListItem>Hospitalized less than 24 hours</asp:ListItem>

<asp:ListItem>Hospitalized more than 24 hours</asp:ListItem>

<asp:ListItem>Physician/Clinic</asp:ListItem>

<asp:ListItem>Minor/Onsite</asp:ListItem>

<asp:ListItem>None</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorInitial"
runat="server"

Text="You must answer this question" ControlToValidate="Initial">

</asp:RequiredFieldValidator>





</td><td colspan="2" valign="top"><font face="Verdana" Size="2"> What Type
of Medical Provider Performed Treatment?

<asp:RadioButtonList font-name="verdana" font-size="10 pt" id=Provider
runat="server">

<asp:ListItem>Hospital</asp:ListItem>

<asp:ListItem>Clinic</asp:ListItem>

<asp:ListItem>Physician</asp:ListItem>


</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorProvider"
runat="server"

Text="You must answer this question" ControlToValidate="Provider">

</asp:RequiredFieldValidator>

<br>

<font face="Verdana" Size="2"> Was Employee admitted into a Hospital?

<asp:RadioButtonList font-name="verdana" font-size="10 pt" id=Admitted
runat="server">

<asp:ListItem>Yes</asp:ListItem>

<asp:ListItem>No</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorAdmitted"
runat="server"

Text="You must answer this question" ControlToValidate="Admitted">

</asp:RequiredFieldValidator>

</td></tr><tr><td colspan="3"><font face="Verdana" Size="2">Medical
Provider - Name, Address, Phone:

<asp:TextBox TextMode="MultiLine" Rows="4" columns= "85" id=med_provider
runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorMed_provider"
runat="server"

Text="You must answer this question" ControlToValidate="Med_Provider">

</asp:RequiredFieldValidator>



</td></tr>

<tr><td colspan="3" bgcolor="MAROON" align="center"> <font face="Verdana"
Size="2" COLOR="WHITE"><strong>ACCIDENT DETAILS</strong></td></tr>

</td></tr>

<tr><td colspan="3"> <font face="Verdana" Size="2"> Give a Full Description
of the Accident:<font Size="1"> (Be as Complete as Possible)

<asp:TextBox TextMode="MultiLine" Rows="5" columns= "85" id=Full
runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorFull" runat="server"

Text="You must answer this question" ControlToValidate="Full">

</asp:RequiredFieldValidator>

</td></tr> <tr><td colspan="3"><font face="Verdana" Size="2"> What Caused
the Injury?

<asp:TextBox id= caused columns="85" runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorCaused" runat="server"

Text="You must answer this question" ControlToValidate="Caused">

</asp:RequiredFieldValidator>

</td></tr> <tr><td><font face="Verdana" Size="2">Did the Accident Occur at
the Work Location?

<asp:RadioButtonList font-name="verdana" font-size="10 pt" id=Occur
runat="server">

<asp:ListItem>Yes</asp:ListItem>

<asp:ListItem>No</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorOccur" runat="server"

Text="You must answer this question" ControlToValidate="Occur">

</asp:RequiredFieldValidator>

</td><td colspan="2" valign="top"> <font face="Verdana" Size="2"> If No,
where did the accident occur?

<asp:textBox Columns = "40" id=where runat=server/>

</td></tr> <tr><td colspan="3"><font face="Verdana" Size="2"> Accident
Address: <br>

<font face="Verdana" Size="2"> Street <asp:TextBox columns="45"
id=accidentStreet runat=server/>

<br><asp:RequiredFieldValidator id="RequiredFieldValidatorAccidentStreet"
runat="server"

Text="Fill this in" ControlToValidate="AccidentStreet">

</asp:RequiredFieldValidator>

<font face="Verdana" Size="2"> City<asp:TextBox columns="20" id =
AccidentCity runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorAccidentCity"
runat="server"

Text="Fill in this field" ControlToValidate="AccidentCity">

</asp:RequiredFieldValidator>

<font face="Verdana" Size="2"> State <asp:TextBox columns="2"
id=AccidentState runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorAccidentState"
runat="server"

Text="You must fill in this field" ControlToValidate="AccidentState">

</asp:RequiredFieldValidator>

<font face="Verdana" Size="2">Zip <asp:TextBox columns = "10" id=AccidentZip
runat=server/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorAccidentZip"
runat="server"

Text="You must fill in this field" ControlToValidate="AccidentZip">

</asp:RequiredFieldValidator>



</td></tr> <tr><td valign="top"><font face="Verdana" Size="2"> Are Other WC
Claims Involved?

<asp:RadioButtonList font-name="verdana" font-size="10 pt" id=OtherClaims
RepeatDirection="Horizontal" Display=dynamic runat="server">

<asp:ListItem>Yes</asp:ListItem>

<asp:ListItem>No</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorOtherClaims"
runat="server"

Text="Required" ControlToValidate="OtherClaims">

</asp:RequiredFieldValidator>

</td><td Valign="top"><font face="Verdana" Size="2"> Safety Devices
Provided?

<asp:RadioButtonList font-name="verdana" font-size="10 pt" id=SafetyDevices
RepeatDirection="horizontal" Display=dynamic runat="server">

<asp:ListItem>Yes</asp:ListItem>

<asp:ListItem>No</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorSafetyDevices"
Display=dynamic runat="server"

Text="Required" ControlToValidate="SafetyDevices">

</asp:RequiredFieldValidator>

</td><td><font face="Verdana" Size="2"> Safety Devices Utilized?

<asp:RadioButtonList font-name="verdana" font-size="10 pt"
id=DevicesUtilized RepeatDirection="Horizontal" runat="server">

<asp:ListItem>Yes</asp:ListItem>

<asp:ListItem>No</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorDevicesUtilized"
Display=dynamic runat="server"

Text="Required" ControlToValidate="DevicesUtilized">

</asp:RequiredFieldValidator>

</td></tr><tr><td><font face="Verdana" Size="2"> Was There a Witness?

<asp:RadioButtonList font-name="verdana" font-size="10 pt" id=Witness
RepeatDirection="Horizontal" Display=dynamic runat="server">

<asp:ListItem>Yes</asp:ListItem>

<asp:ListItem>No</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorWitness"
runat="server"

Text="You must answer this question" ControlToValidate="Witness">

</asp:RequiredFieldValidator>

</td><td valign = "top"><font face="Verdana" Size="2">

If Yes, List Name: <asp:Textbox id="WitnessName" columns="40" runat=server/>

</td></tr>

<tr><td colspan="3" bgcolor="MAROON" align="center">

<font face="Verdana" Size="2" COLOR="WHITE"><strong>DISABILITY
STATUS</strong></td></tr>

</td><td colspan="3"><font face="Verdana" Size="2"> Did Employee Receive Pay
for Date of Injury?

<asp:RadioButtonList RepeatDirection="Horizontal" font-name="verdana"
font-size="10 pt" id=ReceivePay runat="server">

<asp:ListItem>Yes</asp:ListItem>

<asp:ListItem>No</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator id="RequiredFieldValidatorReceivePay"
runat="server"

Text="You must answer this question" ControlToValidate="ReceivePay">

</asp:RequiredFieldValidator>

</td></tr>

<tr><td colspan="3" bgcolor="MAROON" align="center">

<font face="Verdana" Size="2" COLOR="WHITE"><strong>ADDITIONAL COMMENTS &
INFORMATION</strong></td></tr>

<tr><td colspan="3"><font face="Verdana" Size="2"> Additional Comments

<asp:textbox TextMode= "Multiline" Rows= "5" columns= "80"

id="comments" runat=server width="730" height="40"/>

</td></tr>

<tr><td colspan="3"><font face="Verdana" Size="2">How can the above incident
be prevented from happening again?

<asp:textbox id=Prevented Textmode="Multiline" Rows = "5" Columns="80"
width="730" runat=server/>

<tr><td><font face="Verdana" Size="2"><br> Name of person submitting this
form:

<asp:textbox id="Submitter" valign="top" runat=server columns="40"/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorSubmit" runat="server"

Text="You must enter name" ControlToValidate="Submitter">

</asp:RequiredFieldValidator>

</td><td> <font face="Verdana" Size="2">Title <asp:textbox id="Title"
valign="top" runat=server columns="40"/>


</td><td><br>

<font face="Verdana" Size="2">Date<br><asp:textbox id="Today" runat=server
columns="10"/>

<asp:RequiredFieldValidator id="RequiredFieldValidatorToday" runat="server"

Text="You must enter today's date" ControlToValidate="Today">

</asp:RequiredFieldValidator>





</Table>




<tr>

<td>

<asp:Button id="btnSendMail" text="Submit" OnClick="btnSendMail_OnClick"
runat="server" />

</td>

</tr>

<td valign=top> <table cellpadding=20><tr><td>

<asp:ValidationSummary ID="valSum" runat="server" ShowMessageBox="true"
ShowSummary="false" HeaderText="You must enter more information"
Font-Name="verdana" Font-Size="12" /> </td>



</form>





</body>

</html>
 
dancer,

this is because your "offending" line starts in 75 and then gets expanded
with line continuation symbol further down. But for the compiler - this is
all one line, hence the error message.

Hope it makes sense. For easier testing (and maintenance) you may want to
consider the following alternative:

Dim builder As System.Text.StringBuilder = New System.Text.StringBuilder()
builder.Append("start of the string")
builder.Append("second line")
....
builder.Append("last line")
' and then get the result as follows:
Dim myResult As String = builder.ToString()
 
Also, if I take the offending '& StateOfInjury &' out and continue with
other code on the next line, there is NO error.
 
dancer,

1. compiler only reports the start of the line where the error occurred. The
fact that you continue that line with a line continuation symbol "_" is
irrelevant to the compiler - if ANYWHERE between the start of the assignment
statement and the end of it code cannot be compiled, the error will still
display the line where the statement begins.

2. Instead of taking out the offending line - you can actually fix it - just
ensure that you use your textbox' Text property:
'& StateOfInjury.Text &'
 
I tried to fix it. If you will look at my code, it looks exactly as what
you have typed in number2. -- unless I'm not seeing properly. Would you look
at it and see if I'm wrong?

Thank you
 
dancer,

You will need to separate the lines from being an extremely long
concatenated line to one statement involving control reference per line. It
is preferrable to use StringBuilder over concatenating strings, but not
required. Splitting one statement into multiple will add readability and ease
debugging and (later) maintenance of the code. Once you have split the code,
the compiler will tell you the exact line that could not compile. If you
cannot resolve the problem yourself at that point, please post the offending
code, and I will be happy to help.
 
Back
Top