I need to learn how to create a custom class and I do not know where to start.
I am re-designing my old software that displays lab work results for a simulated patient. I need to create a custom class that I can call “LabParameter.”
The LabParameter would have the following properties:
From what I understand based on your initial post, Hemoglobin would be an instance of your LabParameter class. So you would add a new class, name it LabParameter, then add the four properties to it and set their types (looks like they are all strings except the value in the example you wrote). Then you would write:
dim Hemoglobin as new LabParameter
Hemoglobin.Name=“Hb”
Hemoglobin.Value=12
Hemoglobin.Range=“12 - 15”
Hemoglobin.Units=“g/dL”
to set the properties for that instance.
Are you having trouble figuring out where to add the class and its properties in the IDE?
Let’s say that the class is LabParameter then the code could be
Dim Hemoglobin as new LabParameter
Hemoglobin.Name=Hemoglobin
Hemoglobin.Value=13.5
Hemoglobin.Range="13 - 16"
Hemoglobin.Units="g/dL"
Similarly, I can create multiple other instances of the LabParameter that would represent the other lab results such as hematocrit, sodium, potassium etc.
Still, how do I create the LabParameter class with those four properties
Name (as string)
Value (as String)
Range (as String)
Units (as String)
Insert menu -> Class to create the class, then set the name to LabParameter.
Then right click on LabParameter to get a contextual menu, Add to “LabParameter” -> Property, set property name and type. Do this for each property. Then you can reference your class in code as mentioned above.