bryanford
asked on
Problem with VS2005 and not 2003
I just upgraded to VS2005 and in one section of an app ive been working on i get a problem.
Code:
Function GetLegalEmail(ByRef anEmail As String) As String
'Try to extract the legal part of an email e.g. from reply address and return nothing if there is a problem.
Dim eMailParts(2) As String
Dim leftPart As String = ""
Dim rightPart As String = ""
Try
GetLegalEmail = ""
eMailParts = anEmail.Split("@", 2)
leftPart = getLegalFromRight(eMailPar ts(0))
If leftPart = "" Then Exit Function
rightPart = getLegalFromLeft(eMailPart s(1))
If rightPart = "" Then Exit Function
If hasMisplacedDot(leftPart) Then Exit Function
If hasMisplacedDot(rightPart) Then Exit Function
GetLegalEmail = leftPart & "@" & rightPart
Catch ex As Exception
CoutErr(vbNewLine & "GetLegalEmail: " & ex.Message)
End Try
End Function
The error is underlined at eMailParts = anEmail.Split("@", 2)
The error is:
Overload resolution failed because no accessible 'Split' can be called without a narrowing conversion:
'Public Function Split(separator() As Char, options As System.StringSplitOptions) As String()': Argument matching parameter 'separator' narrows from 'String' to '1-dimensional array of Char'.
'Public Function Split(separator() As Char, options As System.StringSplitOptions) As String()': Argument matching parameter 'options' narrows from 'Integer' to 'System.StringSplitOptions '.
'Public Function Split(separator() As Char, count As Integer) As String()': Argument matching parameter 'separator' narrows from 'String' to '1-dimensional array of Char'.
any ideas?
Code:
Function GetLegalEmail(ByRef anEmail As String) As String
'Try to extract the legal part of an email e.g. from reply address and return nothing if there is a problem.
Dim eMailParts(2) As String
Dim leftPart As String = ""
Dim rightPart As String = ""
Try
GetLegalEmail = ""
eMailParts = anEmail.Split("@", 2)
leftPart = getLegalFromRight(eMailPar
If leftPart = "" Then Exit Function
rightPart = getLegalFromLeft(eMailPart
If rightPart = "" Then Exit Function
If hasMisplacedDot(leftPart) Then Exit Function
If hasMisplacedDot(rightPart)
GetLegalEmail = leftPart & "@" & rightPart
Catch ex As Exception
CoutErr(vbNewLine & "GetLegalEmail: " & ex.Message)
End Try
End Function
The error is underlined at eMailParts = anEmail.Split("@", 2)
The error is:
Overload resolution failed because no accessible 'Split' can be called without a narrowing conversion:
'Public Function Split(separator() As Char, options As System.StringSplitOptions)
'Public Function Split(separator() As Char, options As System.StringSplitOptions)
'Public Function Split(separator() As Char, count As Integer) As String()': Argument matching parameter 'separator' narrows from 'String' to '1-dimensional array of Char'.
any ideas?
ASKER
That got rid of the error however now its underlined only the open bracket and says "Expression Expected"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that seems to have done the job. Thanks :)
Do you know why this would work in 2003 and not 2005?
Do you know why this would work in 2003 and not 2005?
Not sure. I can only think that it is a change in the way that strings are stored.
eMailParts = anEmail.Split('@', 2)