Public Class Member


    Public ValidationKey, NamePrefix, FirstName, MiddleNames, LastName, PreferredName, StreetAddress, City, StateProvince, Country, PostalCode, HomePhone, CellPhone, EmailAddress, Gender, Registration As String


Private Sub cmdProcess_Click(sender As Object, e As EventArgs) Handles cmdProcess.Click

        Dim url As String = ""
        Dim m As New Member

        m.ValidationKey = "jv4!)w'yixvV.[ux_D;`rsp@?36ZA=$."
        m.FirstName = "steve"
        m.LastName = "Schimsky"
        m.PreferredName = "schimmer"
        m.Gender = "m"
        m.StreetAddress = "123 one way"
        m.City = "Willingboro"
        m.StateProvince = "NJ"
        m.Country = "USA"
        m.PostalCode = "08046"
        m.HomePhone = "6098711221"
        m.CellPhone = "1234567890"
        m.EmailAddress = ""
        m.StakeholderNo = "123"

        Dim edu As New Education
        edu.Designation = "College Diploma"
        edu.Institute = "123"
        edu.CompletedDate = "1/1/2021"
        edu.ExpiryDate = "1/1/2023"

        Dim Exam As New Exam
        Exam.Language = "English"
        Exam.ExamResult = "Pass"
        Exam.AttemptNo = 1
        Exam.Score = 75
        Exam.ExamDate = "2/2/2021"

        CreateWebRequestPOST(url, m)

    End Sub

    Public Function CreateWebRequestPOST(ByVal strURL As String, objInput As Object) As String

        'Serialize the posted data & convert to bytes
        Dim inputJson = (New JavaScriptSerializer()).Serialize(objInput)

        Dim bytes As Byte() = Encoding.UTF8.GetBytes(inputJson)

        Dim request As HttpWebRequest = DirectCast(WebRequest.Create(strURL), HttpWebRequest)

        request.Method = "POST"
        request.ContentType = "application/json"
        request.Accept = "application/json"
        request.ContentLength = bytes.Length
        request.Expect = "application/json"
        request.GetRequestStream().Write(bytes, 0, bytes.Length)

        'Dim username = "username"
        'Dim password = "passoword"
        'request.Credentials = New NetworkCredential(username, password)

        Using response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
            Dim reader As StreamReader
            Dim rawresp As String
            reader = New StreamReader(response.GetResponseStream())
            rawresp = reader.ReadToEnd()

        End Using

    End Function
    Public BirthDate As String

Notice the “Sub New()” of the Member Class.  It calls a subroutine named: InstantiateProperties.  This subroutine initializes the supporting classes: Education, Exam and Declarations.

    Public StakeholderNo As Integer

    Public Educations As List(Of Education)

    Public Exams As List(Of Exam)

    Public Declarations As List(Of Declaration)

    Public IsAccomodationRequired As Integer



    Public Sub New()



    End Sub


    Private Sub InstantiateProperties()

        Educations = New List(Of Education)()

        Exams = New List(Of Exam)()

        Declarations = New List(Of Declaration)

    End Sub


    Public Sub SetMemberDetails()

    End Sub


End Class


Public Class Education


    Public Designation, Institute As String

    Public CompletedDate, ExpiryDate As String

    Public Qualifying As Boolean


    Public Sub New()

    End Sub


End Class




Public Class Exam


    Public ExamType, Language, ExamResult As String

    Public AttemptNo, Score, SeatAssigned As Integer

    Public ExamDate As String


    Public Sub New()

    End Sub


End Class


Public Class Declaration


    Public DeclarationTitle As String 'Optional: No

    Public QuestionText As String 'Optional: Yes

    Public ClearingAnswer As String 'Optional: Yes

    Public RegistrantAnswer As String 'Optional: No

    Public ResponseDate As String 'Optional: No

    Public Comments 'Optional: yes


    Public Sub New()

    End Sub


End Class