Results 1 to 6 of 6

Thread: Function Error

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    97

    Function Error

    Hello Everybody:
    I am trying to develop a function to concate three strings . When I compile it gives me a compile error .Can anyone tell me whats wrong?

    The error is :
    Method 'Project01.Form1.Variable(string, string, string)' referenced without parentheses


    public string Variable(string UserName, string PhoneNumber, string RemoteYN)
    {
    UserName= txtUserName.Text;
    PhoneNumber= txtPhoneNumber.Text;
    RemoteYN= txtRemoteString.Text;


    return Variable= String.Concat( UserName, PhoneNumber, RemoteYN);

  2. #2
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    I am trying to understand what it is you are doing.

    is this the output u are looking for?

    UserNamePhoneNumberRemoteYN

    Secondly how are you calling this function.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    97

    Function Error

    I am looking for the output as

    UserName PhoneNumber RemoteYN in a text box.

    I am calling the function as :

    private void cmdOutPut_Click(object sender, System.EventArgs e)



    { txtOutput.Text=Variable ;

    }





    Originally posted by Tewl
    I am trying to understand what it is you are doing.

    is this the output u are looking for?

    UserNamePhoneNumberRemoteYN

    Secondly how are you calling this function.

  4. #4
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188

    Re: Function Error

    Originally posted by Rahils573

    private void cmdOutPut_Click(object sender, System.EventArgs e)


    { txtOutput.Text=Variable ;

    }
    You have to pass values with the Variable function

    In you first posted you showed the function as having three parameters so unless you write a function with no parameters you must pass values. For example

    Code:
    txtOutput.Text = Variable(string1, string2, string3);
    plus concat joins the strings together it does not add spaces between the values for you.

    why not do

    Code:
    txtOutput.Text = txtUserName.Text + " " + txtPhoneNumber.Text + " " + txtRemoteString.Text;

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    97

    Function Error

    I tried what u suggessted but it still giving me a error : Says not all code return a value..

    Project01.Form1.Variable(string, string, string)': not all code paths return a value


    Gives error when I define

    public string Variable string UserName, string PhoneNumber, string RemoteYN)




    public string Variable(string UserName, string PhoneNumber, string RemoteYN)
    {
    UserName= txtUserName.Text;
    PhoneNumber= txtPhoneNumber.Text;
    RemoteYN= txtRemoteString.Text;
    }



    private void cmdOutPut_Click(object sender, System.EventArgs e)

    { txtOutput.Text= Variable(UserName,PhoneNumber,RemoteYN);

    txtOutput.Text = txtUserName.Text + " " + txtPhoneNumber.Text + " " + txtRemoteString.Text;

  6. #6
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    PHP Code:
    public void Variable(string UserNamestring PhoneNumberstring RemoteYN)

    UserNametxtUserName.Text;
    PhoneNumbertxtPhoneNumber.Text;
    RemoteYNtxtRemoteString.Text;

    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width