Actually I convert this code into C#...
Function getpatcode()
Dim some = TextBox13.Text
Dim another As Integer
Dim newslip2 As String = "pat-0"
Dim number As String
another = CInt(some.TrimStart("p", "a", "t", "-"))
another += 1
number = another.ToString()
Return newslip2 + number
End Function
public object getpatcode()
{
dynamic some = TextBox13.Text;
int another = 0;
string newslip2 = "pat-0";
string number = null;
another = Convert.ToInt32(some.TrimStart("p", "a", "t", "-"));
another += 1;
number = another.ToString();
return newslip2 + number;
}
But some errors found.. Can anyone check this code?
Regards,
Loading
Suthish NairPosted May 19, 2011, 6:53 AM
fawzan mohamedPosted May 19, 2011, 6:18 AM
public object getpatcode()
{
dynamic some = TextBox13.Text;
int another = 0;
string newslip2 = "pat-0";
string number = null;
another = Convert.ToInt32(some.TrimStart('p', 'a', 't', '-'));
another += 1; number = another.ToString();
return newslip2 + number;
}
VulpesPosted May 18, 2011, 6:44 AM
dynamic some = TextBox13.Text;
just use:
string some = TextBox13.Text;
Although the first line works, it pulls in the dynamic language runtime (DLR) and then uses late binding to determine the type of 'some'. This is unnecessary and just slows down the code.
Posted May 18, 2011, 4:11 AM
can you try this line.
another = Convert.ToInt32((some.TrimStart(new char[] { 'C', 'S', 'E', '-' })));
Mayur GujrathiPosted May 18, 2011, 4:10 AM
Veeramanikandan DhanabalanPosted May 18, 2011, 4:06 AM
When I execute I got this error
Input string was not in a correct format....
private object getId()
{
string some = textBox1.Text;
int another = 0;
string newslip2 = "CSE-0";
string number = null;
another = Convert.ToInt32((some.TrimStart(new char[] { "C", "S", "E", "-" })));
another += 1;
number = another.ToString();
return newslip2 + number;
}
Mayur GujrathiPosted May 18, 2011, 3:53 AM
link for code converter
you can do various things here
Ankit NandekarPosted May 18, 2011, 3:23 AM
Posted May 18, 2011, 3:18 AM
Kindly try the below code and let me know,still you have an issues.
public object getpatcode()
{
dynamic some = TextBox13.Text;
int another = 0;
string newslip2 = "pat-0";
string number = "";
another = Convert.ToInt32(some.TrimStart("p", "a", "t", "-"));
another += 1;
number = another.ToString();
return newslip2 + number;
}