Click here to Skip to main content
15,887,856 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: My.Settings out of scope? Pin
Richard MacCutchan24-Nov-16 2:10
mveRichard MacCutchan24-Nov-16 2:10 
Answer[Resolved] Re: My.Settings out of scope? Pin
Sonhospa24-Nov-16 2:32
Sonhospa24-Nov-16 2:32 
Questionvb.net using string and custom objects Pin
dcof18-Nov-16 17:10
dcof18-Nov-16 17:10 
AnswerRe: vb.net using string and custom objects Pin
Richard MacCutchan18-Nov-16 22:02
mveRichard MacCutchan18-Nov-16 22:02 
GeneralRe: vb.net using string and custom objects Pin
dcof21-Nov-16 5:31
dcof21-Nov-16 5:31 
GeneralRe: vb.net using string and custom objects Pin
Richard MacCutchan21-Nov-16 6:59
mveRichard MacCutchan21-Nov-16 6:59 
GeneralRe: vb.net using string and custom objects Pin
Dave Kreskowiak21-Nov-16 9:28
mveDave Kreskowiak21-Nov-16 9:28 
AnswerRe: vb.net using string and custom objects Pin
David Mujica21-Nov-16 10:56
David Mujica21-Nov-16 10:56 
I'll attempt to answer your question, but if it were me, I think I would re-design this solution. Do you really need to store the letter in the database ? Maybe create a template letter, give it a unique document ID, then you could store multiple records with the student ID, template ID and sequence number.

To answer your question ...

Create a class and call it LetterDetail; at a minimum it would have a string to store the letter.

Create another class and call it MailedLetters; this would contain a List(Of LetterDetail)

The second class gives you the ability to have as many letters as you want grouped together.

Within the second class, you would need 2 methods, Save and Load. This would serialize the object to an XML string which you could then save in the database.

I'll give you some rough code for serialization ...

VB
Public Shared Function Load(sFname As String) As MailedLetters
        Dim xr As XmlReader
        Dim settings As XmlWriterSettings = New XmlWriterSettings()
        settings.Indent = True
        settings.IndentChars = (ControlChars.Tab)
        settings.OmitXmlDeclaration = True

        Dim obj As New MailedLetters
        Dim mySerializer As New XmlSerializer(obj.GetType)

        xr = XmlReader.Create(sFname)

        obj = mySerializer.Deserialize(xr)

        xr.Close()
        xr = Nothing

        Return obj

    End Function

Instead of serializing to a file, you want to serialize it to a string.

VB
Sub Save(sFname As String)
        Dim xw As XmlWriter
        Dim mySerializer As New XmlSerializer(Me.GetType)
        Dim settings As XmlWriterSettings = New XmlWriterSettings()
        settings.Indent = True
        settings.IndentChars = (ControlChars.Tab)
        settings.OmitXmlDeclaration = False

        xw = XmlWriter.Create(sFname, settings)

        mySerializer.Serialize(xw, Me)

        xw.Close()

End Sub
That's the best I can do for you, hope it helps.
Java | [Coffee]
Questionissue in vb script while using MSXML2.ServerXMLHTTP.6.0 object Pin
praveenvb17-Nov-16 0:17
praveenvb17-Nov-16 0:17 
AnswerRe: issue in vb script while using MSXML2.ServerXMLHTTP.6.0 object Pin
Member 1032934426-Jul-17 17:23
Member 1032934426-Jul-17 17:23 
QuestionSet Focus on a textbox after showing form.showdialog() Pin
Hermawan2611-Nov-16 19:46
Hermawan2611-Nov-16 19:46 
AnswerRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard MacCutchan11-Nov-16 23:20
mveRichard MacCutchan11-Nov-16 23:20 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard Deeming12-Nov-16 3:55
mveRichard Deeming12-Nov-16 3:55 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard MacCutchan12-Nov-16 4:33
mveRichard MacCutchan12-Nov-16 4:33 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard Deeming12-Nov-16 4:37
mveRichard Deeming12-Nov-16 4:37 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard MacCutchan12-Nov-16 4:46
mveRichard MacCutchan12-Nov-16 4:46 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard Deeming12-Nov-16 5:48
mveRichard Deeming12-Nov-16 5:48 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard MacCutchan12-Nov-16 21:28
mveRichard MacCutchan12-Nov-16 21:28 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Dave Kreskowiak12-Nov-16 6:47
mveDave Kreskowiak12-Nov-16 6:47 
GeneralRe: Set Focus on a textbox after showing form.showdialog() Pin
Richard Deeming12-Nov-16 11:44
mveRichard Deeming12-Nov-16 11:44 
QuestionWhy this sub is executed 3 times ? Pin
desanti7-Nov-16 18:26
desanti7-Nov-16 18:26 
AnswerRe: Why this sub is executed 3 times ? Pin
Eddy Vluggen11-Nov-16 7:17
professionalEddy Vluggen11-Nov-16 7:17 
GeneralRe: Why this sub is executed 3 times ? Pin
desanti11-Nov-16 19:28
desanti11-Nov-16 19:28 
GeneralRe: Why this sub is executed 3 times ? Pin
Eddy Vluggen12-Nov-16 1:42
professionalEddy Vluggen12-Nov-16 1:42 
QuestionMy application does not close anymore Pin
desanti31-Oct-16 12:33
desanti31-Oct-16 12:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.