Reputation: 95
So, I wrote this code that takes in information entered by a user.
Public Class Patient
Private Sub Patient_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = "First Name:"
Label2.Text = "Last Name:"
Label3.Text = "Address: "
Label4.Text = "City:"
Label5.Text = "Province: "
Label6.Text = "Postal Code: "
Label7.Text = "Health Card Number: "
If (CollectionIndexValue <> -1) Then
Dim existingPatient As New PatientObject4
existingPatient = PatientCollection(CollectionIndexValue)
TextBox1.Text = existingPatient.Firstname
TextBox2.Text = existingPatient.LastName
TextBox3.Text = existingPatient.Address
TextBox4.Text = existingPatient.City
TextBox5.Text = existingPatient.Province
TextBox6.Text = existingPatient.PostalCode
TextBox7.Text = existingPatient.HealthCardNumber
Button1.Text = "Save"
Else
Button1.Text = "Add"
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or
TextBox5.Text = "" Or TextBox6.Text = "" And TextBox7.Text = "") Then
Label8.Text = "All fields must be populated"
Else
If (Button1.Text.ToUpper() = "ADD") Then
Dim PatientObject As New PatientObject4
PatientObject.Firstname = TextBox1.Text
PatientObject.LastName = TextBox2.Text
PatientObject.Address = TextBox2.Text
PatientObject.City = TextBox4.Text
PatientObject.Province = TextBox5.Text
PatientObject.HealthCardNumber = TextBox7.Text
PatientCollection.Add(PatientObject)
Label8.Text = "Patient Added"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
Else
Dim PatientSave As New PatientObject4
PatientSave.Firstname = TextBox1.Text
PatientSave.LastName = TextBox2.Text
PatientSave.Address = TextBox3.Text
PatientSave.City = TextBox4.Text
PatientSave.Province = TextBox5.Text
PatientSave.PostalCode = TextBox6.Text
PatientSave.LastName = TextBox7.Text
PatientCollection(CollectionIndexValue) = PatientSave
Label8.Text = "Patient Saved"
End If
End If
End Sub
End Class
If I want this information to be save to a text file (create a new text file) when a new patient is added. How would go about doing that? I tried to google it, but it a bit hard when you don't know what you're looking for.
Any help/ideas would be very much appreciated.
Thanks.
P.S. This is just a snippet of a larger code. Thanks.
Upvotes: 0
Views: 562