dc

dc

  • NA
  • 663
  • 0

vb.net 2010 string object and custom object

Nov 18 2016 11:13 PM
In a vb.net 2010 application, I am trying to determine the best way to accomplish this goal. Write now 1 letter is generated and sent to one guardian. However this application needs to be changed so that the same exact letter can be send to different mailing addresses since each student may have more than one parent/guardian at different mailing addresses. So basically I want to generate
more than one letter with the same wording. The only differences between the letters would be the mailing addresses. I want the letters to be written to the same varchar(max) column in a sql server 2012 database. The letters will be in the same field since the data will be sent to a sql server reporting server where the letters will be generated one after each other.
Right now the letters are written to the 'Dim _al As Letters = New Letters()' object. The only way I know to modify text data is to use a string or stringbuilder objects. I do not know yo modify data is other objects. Basically I want to use a string.replace logic to replace the addresses in the second letter. I also want to usestringbuilder.append to place more than one letter following another to be placed in the osne varchar(max) field.
I know I can use the following code to convert a custom object to a string.
 Dim _LetterStr As String = String.Empty
 Dim _LetterStrbldr As StringBuilder = New StringBuilder
 _LetterStr = _Letter.Letter.ToString()

However I do not know how to convert a string object back to a custom object.Here is the original code of the application:

#Region "Protected Sub btnSubmitModifiedLetter_Click(ByVal sender As Object,  ByVal e As System.EventArgs) Handles btnSubmitModifiedLetter.Click"      Protected Sub btnSubmitModifiedLetter_Click(ByVal sender As Object, ByVal e  As System.EventArgs) Handles btnSubmitModifiedLetter.Click          Dim _al As Letters = New Letters()          Dim _infinteCampusText As String          Dim _Letter As Letter = New Letter()          Dim _startDate As DateTime = Now()          Dim _term As Integer = 0                   _Letter.SchoolYear = _schoolyear          _Letter.Term = _term          _Letter.Milestone = ddlMilestone.SelectedValue          _Letter.SchoolNumber = Right("000" & ddlSchools.SelectedValue,3)          _Letter.Printed = "Y"          _Letter.Letter = reLetterEditor.Content          _Letter.StudentLink = Right("0000000" & txtStuLink.Text, 7)          _Letter.Language = txtLanguage.Text            _infinteCampusText = _al.BuildText(_Letter)              _al.InsertData(_Letter, _infinteText)            btnProcessSelections.Visible = False          gvLetters.DataSourceID = String.Empty          gvLetters.DataBind()          gvLetters.Visible = False          Response.Redirect("letter.aspx?schoolyear=" +  _Letter.SchoolYear.ToString() + "&schoolnum=" +  _Letter.SchoolNumber.ToString() + "&term=" +  _Letter.Term.ToString() + "&milestonecode=" +  _Letter.Milestone.ToString() + "&startdate=" + _startDate.ToString() +  "&enddate=" + DateAdd(DateInterval.Day, 1, Today()).ToString() +  "&language=ALL&studentlink=ALL")        End Sub  #End Region 

Thus can you show me the code to convert a string object to a custom object and/or show me code on how to accomplish my goal?


Answers (1)