|
-
August 7th, 2009, 04:01 AM
#1
[RESOLVED] Type mismatch
Hey. Not sure if this should go here, but I am getting this error from the code below:
Script error detected at line 14.
Source line: If player_names(player_no) = "" Then
Description: Type mismatch: 'player_names'
Code:
<%
' Used to get an array of a specific teams players' atttributes (e.g. name, goals, points)
Function get_player_attributes(team_no, players_per_team, attribute_name)
Dim player_attributes()
ReDim player_attributes(players_per_team)
For player_no = 0 To players_per_team Step 1
player_attributes(player_no) = Request.form("team_" & team_no & "_player_" & player_no + 1 & "_" & attribute_name)
Next
get_players_attributes = player_attributes
End Function
' Validates a player's name.
Function validate_players_name(team_no, player_no, player_names)
If player_names(player_no) = "" Then
' Player name is blank.
Response.Write("Player #" & player_no + 1 & "'s name must not be blank.") %> <br/> <%
Else
' Only check if this name is a duplicate if it is not blank.
For dup_check_no = 0 To UBound(player_names)
' Check against all other names to see if this is a duplicate.
If player_no <> dup_check_no And player_names(player_no) = player_names(dup_check_no) Then
' Isn't checking an element against itself and elements are equal; is a duplicate.
Response.Write("Player #" & player_no + 1 & "'s name (" & _
player_names(player_no) & ") must be unique.") %> <br/> <%
' Only need to warn once.
Exit For
End If
Next
End If
End Function
' Validates a player's points.
Function validate_players_points(team_no, player_no, player_points)
If player_points = "" Then
Response.Write("Player #" & player_no + 1 & "'s points must not be blank.") %> <br/> <%
ElseIf Not IsNumeric(player_points) Then
' Only check if non-numeric if it is not blank.
Response.Write("Player #" & player_no + 1 & "'s points (" & _
player_points & ") must be a numeral.") %> <br/> <%
End If
End Function
' Validates a player's goals.
Function validate_player_goals(team_no, player_no, player_goals)
If player_goals = "" Then
Response.Write("Player #" & player_no + 1 & "'s goals must not be blank.") %> <br/> <%
ElseIf Not IsNumeric(player_goals) Then
' Only check if non-numeric if it is not blank.
Response.Write("Player #" & player_no + 1 & "'s goals (" & _
player_goals & ") must be a numeral.") %> <br/> <%
End If
End Function
Dim players_per_team
players_per_team = 22
' Validate team 1's players' attributes.
Dim team_1_player_names
team_1_player_names = get_player_attributes(1, players_per_team, "name")
Call validate_players_name(1, 0, team_1_player_names)
%>
I'm still learning asp/vbscript so I don't know why it's complaining.
Cheers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|