Download one of the sample gint project file and library from here and copy paste this code at the end. I used the "Gr023" as my base. Modify the table names highlighted below to match your project. Add the SPTN funtion in the gINT rules Save section of the SAMPLE table properties.
Public Sub SPTN
'*****************************************************
'Description: Calculates SPT N
'*****************************************************
Const s_Field_BLOWS_1ST_6IN As String = "BLOWS_1ST_6IN"
Const s_Field_BLOWS_2ND_6IN As String = "BLOWS_2ND_6IN"
Const s_Field_BLOWS_3RD_6IN As String = "BLOWS_3RD_6IN"
Const s_Field_SPTN As String = "SPTN"
Dim iPsBLOWS_1ST_6IN As Integer 'Pointer to BLOWS_1ST_6IN
Dim iPsBLOWS_2ND_6IN As Integer 'Pointer to BLOWS_2ND_6IN
Dim iPsBLOWS_3RD_6IN As Integer 'Pointer to BLOWS_3RD_6IN
Dim iPsSPTN As Integer 'Pointer to SPTN
Dim lRow As Long
Dim StrSPTN As String
Dim iBLOWS_1ST_6IN As Integer
Dim iBLOWS_2ND_6IN As Integer
Dim iBLOWS_3RD_6IN As Integer
Dim iSPTN As Integer
'Obtain pointers to the field data within the data array.
If InitFieldsFnB(s_Field_BLOWS_1ST_6IN, iPsBLOWS_1ST_6IN, _
s_Field_BLOWS_2ND_6IN, iPsBLOWS_2ND_6IN, _
s_Field_BLOWS_3RD_6IN, iPsBLOWS_3RD_6IN, _
s_Field_SPTN, iPsSPTN) _
Then
MsgBox ("One or more of the required fields missing from the table.", vbOkOnly + vbExclamation, "Error - SPT N Calc")
Exit Sub
End If
With gINTRules.GridData
'Spin through the rows on the table and perform the calc
For lRow = 1 To glNumRows
If CStr(gsDataA(iPsBLOWS_1ST_6IN, lRow)) Like "*/*" Then
iBLOWS_1ST_6IN = 100
Else
iBLOWS_1ST_6IN = 0
End If
If IsNumeric(gsDataA(iPsBLOWS_2ND_6IN, lRow)) Then 'Get BLOWS_2ND_6IN
iBLOWS_2ND_6IN = CInt(gsDataA(iPsBLOWS_2ND_6IN, lRow))
ElseIf CStr(gsDataA(iPsBLOWS_2ND_6IN, lRow)) Like "*/*" Then
iBLOWS_2ND_6IN = 100
Else
iBLOWS_2ND_6IN = 0
End If
If IsNumeric(gsDataA(iPsBLOWS_3RD_6IN, lRow)) Then 'Get BLOWS_3RD_6IN
iBLOWS_3RD_6IN = CInt(gsDataA(iPsBLOWS_3RD_6IN, lRow))
ElseIf CStr(gsDataA(iPsBLOWS_3RD_6IN, lRow)) Like "*/*" Then
iBLOWS_3RD_6IN = 100
Else
iBLOWS_3RD_6IN = 0
End If
iSPTN = iBLOWS_1ST_6IN + iBLOWS_2ND_6IN + iBLOWS_3RD_6IN
If iSPTN > 100 Then
iSPTN = 100
End If
If Len(gsDataA(iPsBLOWS_1ST_6IN, lRow)) > 0 Then
gsDataA(iPsSPTN, lRow) = CStr(iSPTN)
End If
Next lRow
End With
End Sub
No comments:
Post a Comment