I have been stuck on this problem with no solution found on the web. I have tried to change a few things around to no avail.
My problem is that I can't seem to call a function within a structure in VB. My structure looks as follows:
Private Structure patient
Public givenName As String
Public assignedDoctors() As String
Public doctorCount As Integer
Public infected As Boolean
Private pID As Double
'Simple status subprocedure
Public Sub ChangeStatus(ByVal status As String)
Select Case status
Case "positive"
infected = True
givenName = "{" & givenName & "}"
Case "tested"
infected = False
givenName = $"[{givenName}]"
Case "negative"
infected = False
givenName = $"<{givenName}>"
Case "untested"
infected = False
givenName = $"*{givenName}"
End Select
End Sub
Public Sub AddDoctor(ByRef doctor As String)
doctorCount += 1
ReDim Preserve assignedDoctors(doctorCount)
assignedDoctors(doctorCount) = doctor
End Sub
End Structure
My error occurs on the following line:
Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
Dim rPatient As patient
rPatient = New patient
rPatient.givenName = txtPatientName.Text
rPatient.doctorCount = 1
rPatient.assignedDoctors(1) = cbDoctor.Text
Call rPatient.ChangeStatus(status:=cbStatus.Text)
ArrayFix(rPatient.assignedDoctors, rPatient.givenName, rPatient.infected)
End Sub
rPatient is an instance of the structure patient. My error occurs on the "Call" line. The error being: "Object reference not set to an instance of an object." I have tried to make the patient structure "shared" but I do not know how the shared parameter works and have attempted to learn it without progress.
If anyone could point me in the right direction it would be very helpful. Thanks.