The following code is used to take the GPA a student enters in a form and then load it into an external table which then imports into our student management system.
The option to enter a GPA is only shown if the student chooses "Yes" to the question "Are you a beginning freshman?" If they select no, the value being imported into the table is shown as "0". This wouldn't customarily be an issue, except that if a GPA already exists (say it was manually entered, or if it was loaded in a different way), it's being overwritten with a "0". I can see where the "0" is coming from based on the code below, but I'm curious as to what the best way is to return a "NULL" value if the student is not a beginning Freshman.
(Additionally, I did not write this code, nor am I great at code, so this may not be even a good way to do it, and I'm open to suggestions.)
Dim GPAbeforPt, GPAafterPT As String GPAafterPT = HSGPA.Substring(HSGPA.IndexOf(".") + 1) GPAbeforPt = Left(HSGPA, 1) If Len(GPAafterPT) < 2 Then GPAafterPT = GPAafterPT & "0" End If
HSGPA = GPAbeforPt & GPAafterPT
The rest of the code is set up where the value of "HSGPA" is imported.
Edit: The purpose of the "GPAafterPT & '0'" in the code listed above is so if a student enters a GPA of 3.2, the code adds a zero so it becomes 3.20 which is what our system has to see.