My attempt at reversing it was...
Quote:
>
>
>
Public Function GetScore(NCLGym As Text) As String
NCLGym = Nz(NCLGym, 0)
Select Case NCLGym
Case Is = "8a"
GetScore = 36
Case Is = "8b"
GetScore = 34
Case Is = "8c"
GetScore = 32
Case Is = "7a"
GetScore = 30
Case Is = "7b"
GetScore = 28
Case Is = "7c"
GetScore = 26
Case Is = "6a"
GetScore = 24
Case Is = "6b"
GetScore = 22
Case Is = "6c"
GetScore = 20
Case Is = "5a"
GetScore = 18
Case Is = "5b"
GetScore = 16
Case Is = "5c"
GetScore = 14
Case Is = "4a"
GetScore = 12
Case Is = "4b"
GetScore = 10
Case Is = "4c"
GetScore = 8
Case Is = "3a"
GetScore = 6
Case Is = "3b"
GetScore = 4
Case Is = "3c"
GetScore = 2
Case Is = "W"
GetScore = 0
Case Else
GetScore = "U"
End Select
End Function
>
|
I wouldn't do this with VB at all. I'd use SQL. As long as you have a
fixed number of possible values, just put all the (textscore, numeric
score) combinations in a table, and then just use a simple SQL
statement.
Something along the lines of:
Option Compare Database
Public Function ConvertScore(ByVal strScore As String) As Integer
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT NumericScore FROM tblScores WHERE TextScore = '" &
strScore & "';"
Set rs = DBEngine(0)(0).OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount = 0 Then
ConvertScore = 0
Else
ConvertScore = rs.Fields(0)
End If
rs.Close
Set rs = Nothing
End Function