Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

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(eMailParts(0))
            If leftPart = "" Then Exit Function
            rightPart = getLegalFromLeft(eMailParts(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?
0
bryanford
Asked:
bryanford
  • 3
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
Try changing it to:

    eMailParts = anEmail.Split('@', 2)
0
 
bryanfordAuthor Commented:
That got rid of the error however now its underlined only the open bracket and says "Expression Expected"
0
 
Carl TawnSystems and Integration DeveloperCommented:
Ok, scratch that. Try:

    eMailParts = anEmail.Split("@".ToCharArray(), 2)
0
 
bryanfordAuthor Commented:
that seems to have done the job. Thanks :)

Do you know why this would work in 2003 and not 2005?
0
 
Carl TawnSystems and Integration DeveloperCommented:
Not sure. I can only think that it is a change in the way that strings are stored.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now