issue when converting C#.net code into vb.net

Discussion in 'ASP .Net Web Controls' started by Dhananjay, Jan 29, 2008.

  1. Dhananjay

    Dhananjay Guest

    Hi All,

    I am facing problem when i am converting C#.net code(Delegate concept)
    into vb.net. I am unable to do that . Can someone help me to solve the
    problem. I am providing my C#.net code.

    ==================================my code is :-
    ======================================
    [DataObjectMethod(DataObjectMethodType.Select, false)]
    static public List<MembershipUserWrapper> GetMembers(bool
    returnAllApprovedUsers, bool returnAllNotApprovedUsers,
    string usernameToFind, string sortData)
    {

    List<MembershipUserWrapper> memberList = new
    List<MembershipUserWrapper>();

    // See if we are looking for just one user
    if (usernameToFind != null)
    {
    MembershipUser mu =
    Membership.GetUser(usernameToFind);
    if (mu != null)
    {
    MembershipUserWrapper md = new
    MembershipUserWrapper(mu);
    memberList.Add(md);
    }
    }
    else
    {
    MembershipUserCollection muc =
    Membership.GetAllUsers();
    foreach (MembershipUser mu in muc)
    {
    if ((returnAllApprovedUsers == true &&
    mu.IsApproved == true) ||
    (returnAllNotApprovedUsers == true &&
    mu.IsApproved == false))
    {
    MembershipUserWrapper md = new
    MembershipUserWrapper(mu);
    memberList.Add(md);
    }
    }

    if (sortData == null)
    {
    sortData = "UserName";
    }
    if (sortData.Length == 0)
    {
    sortData = "UserName";
    }


    string sortDataBase = sortData;
    string descString = " DESC";
    if (sortData.EndsWith(descString))
    {
    sortDataBase = sortData.Substring(0,
    sortData.Length - descString.Length);
    }

    Comparison<MembershipUserWrapper> comparison = null;

    switch (sortDataBase)
    {
    case "UserName":
    comparison = new
    Comparison<MembershipUserWrapper>(
    delegate(MembershipUserWrapper lhs,
    MembershipUserWrapper rhs)
    {
    return
    lhs.UserName.CompareTo(rhs.UserName);
    }
    );
    break;
    case "Email":
    comparison = new
    Comparison<MembershipUserWrapper>(
    delegate(MembershipUserWrapper lhs,
    MembershipUserWrapper rhs)
    {
    if (lhs.Email == null | rhs.Email ==
    null)
    {
    return 0;
    }
    else
    {
    return
    lhs.Email.CompareTo(rhs.Email);
    }
    }
    );
    break;
    case "CreationDate":
    comparison = new
    Comparison<MembershipUserWrapper>(
    delegate(MembershipUserWrapper lhs,
    MembershipUserWrapper rhs)
    {
    return
    lhs.CreationDate.CompareTo(rhs.CreationDate);
    }
    );
    break;
    case "IsApproved":
    comparison = new
    Comparison<MembershipUserWrapper>(
    delegate(MembershipUserWrapper lhs,
    MembershipUserWrapper rhs)
    {
    return
    lhs.IsApproved.CompareTo(rhs.IsApproved);
    }
    );
    break;
    case "IsOnline":
    comparison = new
    Comparison<MembershipUserWrapper>(
    delegate(MembershipUserWrapper lhs,
    MembershipUserWrapper rhs)
    {
    return
    lhs.IsOnline.CompareTo(rhs.IsOnline);
    }
    );
    break;
    case "LastLoginDate":
    comparison = new
    Comparison<MembershipUserWrapper>(
    delegate(MembershipUserWrapper lhs,
    MembershipUserWrapper rhs)
    {
    return
    lhs.LastLoginDate.CompareTo(rhs.LastLoginDate);
    }
    );
    break;
    default:
    comparison = new
    Comparison<MembershipUserWrapper>(
    delegate(MembershipUserWrapper lhs,
    MembershipUserWrapper rhs)
    {
    return
    lhs.UserName.CompareTo(rhs.UserName);
    }
    );
    break;
    }

    if (sortData.EndsWith("DESC"))
    {
    memberList.Sort(comparison);
    memberList.Reverse();
    }
    else
    {
    memberList.Sort(comparison);
    }

    }

    return memberList;

    }
    ====================================C#.net code
    end==================================

    now i want this part of code into vb.net code , can some one please
    provide me the solution.
    I had tried writing myself C#.net code into vb.net code but unable to
    acheive correct vb.net code.I had used some conversion tool also from
    developer fusion site but it is showing error that is some different
    kind of error.Please provide me the vb.net code.
    it's urgent

    Thanks in advance
    Dhananjay
     
    Dhananjay, Jan 29, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dhananjay
    Replies:
    3
    Views:
    483
    PhilTheGap
    Feb 4, 2008
  2. Andy Luotto
    Replies:
    1
    Views:
    518
  3. Replies:
    6
    Views:
    1,352
  4. Replies:
    1
    Views:
    409
  5. Dhananjay

    issue when converting C#.net code into vb.net

    Dhananjay, Jan 29, 2008, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    374
    Dhananjay
    Jan 31, 2008
Loading...

Share This Page