Using Split Property on TextBox - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Using Split Property on TextBox

hollyquinnhollyquinn Posts: 1Member

I want to have a TextBox where the user can enter in emails and these emails can be passed to an SMTP function where it is added to the message as a CC. I'm using the below code to try and add a ; in between each email before it is passed to the function. The problem is, it doesn't work. It also doesn't throw any errors. Can anyone tell me what I am doing wrong. If any other info is needed please let me know also. Thanks.


Dim mcc As String

Dim cccopy As String

mcc = nvarP7copy.Text.ToString


If mcc <> "" Or mcc <> String.Empty Then

Dim strCC() As String = Split(mcc, ";")
Dim strThisCC As String

For Each strThisCC In strCC
cccopy = Trim(strThisCC)
Next

End If



Comments

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    You code looks alright... but maybe the split command is messin' ya up. I would try using the split function that is built into the string class like this:

    [code]
    Dim mcc As String
    Dim cccopy As String

    mcc = nvarP7copy.Text.ToString

    If mcc <> "" Or mcc <> String.Empty Then

    Dim strCC() As String = mcc.Split(";")
    Dim strThisCC As String

    For i as integer = 0 to strCC.Length - 1
    cccopy = strCC(i).Trim()
    Next

    End If
    [/code]

    See if that works for you, I am doing the same thing, just using the functions built inside the objects rather then the functions u were using
  • DrMartenDrMarten Posts: 748Member
    Hi,

    Firstly, how is the user entering emails into the TextBox?

    The Split command will remove the ";" or semi-colons, NOT add them.

    If the user enters something like.>>

    [email protected];[email protected];[email protected]

    What do you want to happen?


    Regards,

    Dr M.


Sign In or Register to comment.