Hi,
This seems to be a simple piece of code but I keep getting a type mismatch error on CInt. Have tried CSng, CDbl as well but get a similar mismatch error.
Confirmed, using TypeName, that intTemp is Integer and strTemp is string.
Scenario is that I have a table of up to five entries on an input form that the user can fill out. The total of these entries must equal 30. The field names on the user form are RegPct0 thru RegPct4.
Can anyone see what I'm missing?
Thanks in advance.
Code:
dim intCounter
dim intTotPct
dim strTemp
dim intTemp
intCounter = 0
intTotPct = 0
intTemp = 0
For intCounter = 0 To 4
strPctField = "RegPct" & intCounter
If Request.Form.Item(strPctField) <> "" Then
strTemp = Request.Form.Item(strPctField)
intTemp = cint(strTemp)
End If
intTotPct = intTotPct + intTemp
Next
This seems to be a simple piece of code but I keep getting a type mismatch error on CInt. Have tried CSng, CDbl as well but get a similar mismatch error.
Confirmed, using TypeName, that intTemp is Integer and strTemp is string.
Scenario is that I have a table of up to five entries on an input form that the user can fill out. The total of these entries must equal 30. The field names on the user form are RegPct0 thru RegPct4.
Can anyone see what I'm missing?
Thanks in advance.
Code:
dim intCounter
dim intTotPct
dim strTemp
dim intTemp
intCounter = 0
intTotPct = 0
intTemp = 0
For intCounter = 0 To 4
strPctField = "RegPct" & intCounter
If Request.Form.Item(strPctField) <> "" Then
strTemp = Request.Form.Item(strPctField)
intTemp = cint(strTemp)
End If
intTotPct = intTotPct + intTemp
Next