Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting C# to VB.NET: why is static method not visible?

Tags:

methods

c#

vb.net

I have a C# method in my datatier that I am trying to convert to VB.Net. I converted it to VB.Net but when I bring up the datatier class the method is not showing. It has been a long time since i have used VB.Net and forgot alot of things

Here is my c# method:

public static useraccount UserActInfo(string empnumber)
{
    SQLConnectivity db = new SQLConnectivity();
    SqlParameter[] param = new SqlParameter[1];
    DataTable dt = new DataTable();
    useraccount user = new useraccount();

    param[0] = db.MakeInputParameter("@UserEmpNumber", empnumber);
    db.RunExecuteProcedure("dc_SELECT_UserActInfo_By_EmpNumber", param, ref dt);

    if (dt != null && dt.Rows.Count > 0)
    {
        user.ID = Convert.ToInt32(dt.Rows[0]["UserID"].ToString());
        user.FirstName = dt.Rows[0]["FName"].ToString();
        user.LastName = dt.Rows[0]["LName"].ToString();
        user.MiddleName = dt.Rows[0]["MName"].ToString();
        user.Title = dt.Rows[0]["Title"].ToString();
        user.PhoneNo1 = dt.Rows[0]["PhoneNumber1"].ToString();
        user.PhoneNo2 = dt.Rows[0]["PhoneNumber2"].ToString();
        user.Fax = dt.Rows[0]["FaxNumber"].ToString();
        user.Email = dt.Rows[0]["Email"].ToString();
        user.StreetAddress = dt.Rows[0]["StreetAddress"].ToString();
        user.Locality = dt.Rows[0]["Locality"].ToString();
        user.Province = Convert.ToInt32(dt.Rows[0]["Province"].ToString());
        user.PostalCode = dt.Rows[0]["PostalCode"].ToString();
        user.EmpNumberID = Convert.ToInt32(dt.Rows[0]["EmployeeNumberID"].ToString());
        user.EmpNumber = dt.Rows[0]["EmployeeNumber"].ToString();
    }
    if (user.ID != 0) { return user; }
    else { return null; }
}

I believe it has to do with the declaration, which i have as:

Public Static Function UserActInfo(ByVal _eno As String) As useraccount

Why can I not see the method

like image 875
mattgcon Avatar asked Sep 14 '11 23:09

mattgcon


People also ask

What are type conversions in C?

Typecasting is a method in C language of converting one data type to another. There are two types of typecasting. 1. Implicit Type casting − This conversion is done by the compiler. When more than one data type of variables are used in an expression, the compiler converts data types to avoid loss of data.

Can you convert data types in C?

In C, When you convert the data type of a variable to another data type then this technique is known as typecasting. Let's say that you want to store a value of int data type into a variable of float data type. Then you can easily do this with the help of typecasting.

How many conversion are there in C?

There are two type of type conversion: implicit and explicit type conversion in C.

What is casting in C?

Type Casting is basically a process in C in which we change a variable belonging to one data type to another one. In type casting, the compiler automatically changes one data type to another one depending on what we want the program to do.


1 Answers

Static in C# is Shared in VB.Net.

So if you convert your code above it will be:

 Public Shared Function UserActInfo(ByVal empNumber As String) As UserAccount
     'code here
 End Function

You could use this online converter by Telerik to help you with the conversions.

like image 190
Annie Lagang Avatar answered Sep 22 '22 07:09

Annie Lagang