Click here to Skip to main content
15,908,909 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
function start( int a)
{
   // code here
}


Now I want to pass textbox value as a argumnet when I will call function how can I pass the value of textbox as argument in function.
Posted
Updated 9-Oct-14 3:22am
v2
Comments
[no name] 9-Oct-14 9:14am    
Convert the string to an integer
Member 10874581 9-Oct-14 9:15am    
can u give a example please
Afzaal Ahmad Zeeshan 9-Oct-14 9:21am    
See my answer.
[no name] 9-Oct-14 9:41am    
Read the documentation for int.Parse and int.TryParse. Do not do it the solution 2 way though.
[no name] 9-Oct-14 9:58am    
where is the problem. How have you tried please show your code

Do it this way,

C#
// call function, 
// the text was converted to integer
start(Convert.ToInt32(textBox.Text));


The text (string) was converted to numberic (int) type because you're having parameter designed to be an int.

Or convert the parameter to a string type as Solution 1.

C#
start(string a)
{
   // code here
}

/* call it as */
start(textBox.Text);
 
Share this answer
 
v4
Pass TextboX Value Directly as String
C#
function start( string a)
{
//your Code
}



start(txtbox.Text);//call the Method
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900