none
vb.net 2010 field/ column edit RRS feed

  • Question

  • In a vb.net 2010 application, I have the following code setup so far:
     
    Dim _dtEmailaddress As DataTable = SelectEmailAddress(_dtPersonID(0)("SPA_PersonID"))
                Dim _email As String = String.Empty
                If _dtEmailaddress.Rows.Count > 0 Then
                    If IsDBNull((_dtEmailaddress(0)("email"))) Then
                        _letter = _letter.Replace("&SPA_EMAIL.EVAL", "")
                    Else
                        _letter = _letter.Replace("&SPA_EMAIL.EVAL", _dtEmailaddress(0)("email"))
                    End If
                End If

    I need to be able to check for  email addresses that end with '@opd.org' in the reference called _dtEmailaddress(0)("email").

    Thus can you show me the vb.net code so I would know how to use only email addresses that end with '@opd.org' in the ((_dtEmailaddress(0)("email")) field ?


    Thursday, October 26, 2017 8:51 PM

Answers

  • See if this is what you are after

    Dim _dtEmailaddress As New DataTable
    _dtEmailaddress.Columns.Add(New DataColumn With
    {
        .ColumnName = "email",
        .DataType = GetType(String)
    })
    _dtEmailaddress.Rows.Add(New Object() {"Hello@ppd.org"})
    _dtEmailaddress.Rows.Add(New Object() {"Hello@opd.org"})
    
    If _dtEmailaddress.Rows(1).Field(Of String)("email").EndsWith("@opd.org") Then
        Console.WriteLine("Found")
    Else
        Console.WriteLine("not Found")
    End If

    You need this reference in your project.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Thursday, October 26, 2017 10:09 PM
    Moderator