Forum Moderators: open
Invalid use of Null: 'Split'
/mypage.asp, line 131
I wonder can someone help me here?
------------------------------------
First piece of code
------------------------------------
<% if NOT RsMembers.EOF then
Dim myKeywordArray
myKeywordArray = Split(RsMembers("mSkills"), ",")
if isarray(myKeywords) then
For i = 0 to UBound(myKeywordArray)
response.write "<a href='membersearch.asp?mSkills=" & Trim(myKeywordArray(i)) & "'>" & Trim(myKeywordArray(i)) & "</a>, "
Next
Else
response.write ("No skills entered.") End if
End if %>
------------------------------------
Second piece of code
------------------------------------
<% if NOT RsMembers.EOF then
Dim myKeywordArray
myKeywordArray = Split(RsMembers("mSkills"), ",")
For i = 0 to UBound(myKeywordArray)
response.write "<a href='membersearch.asp?mSkills=" & Trim(myKeywordArray(i)) & "'>" & Trim(myKeywordArray(i)) & "</a>, "
Next
Else
response.write ("No skills entered.") End if
%>
I am not sure on the exact syntax, it has been a while for me and VB but you want to test to see if the array has a null value first... something like
if RsMembers("mSkills") != Null then
Dim myKeywordArray
myKeywordArray = Split(RsMembers("mSkills"), ",")
else
response.write ("No skills entered.")
If RsMembers("mSkills") should never be Null then you need to look at why it is getting a null value.
Another way of doing this is by error handling, I am not sure which is best suited for you in this case. I would do the test rather than the error handling, but if using error handling makes more sense for your app it would look something like this:
(again this is pseudo-code, syntax is wrong)
try
myKeywordArray = Split(RsMembers("mSkills"), ",")
except error E
if E.message = "Invalid use of Null: 'Split' then
myKeywordArray = []
.......
You can also set the array to be empty and then pass it to your loop... something like this...
Dim myKeywordArray
if RsMembers("mSkills") != Null then
myKeywordArray = Split(RsMembers("mSkills"), ",")
else
myKeywordArray = []
Play around with what method works best for the rest of your code... if you have more questions please ask.