VB.NET
I am pulling the values from a database using a Querystring.
Example values:
1.1
2.1
10.1
11.1
Is there a way to format the string so that it onlys shows the numbers before the decimal point?
Ex. 1.1 = 1, 10.1 = 10, etc.
I tried the code below but it only shows the first number.
string strNumber = Request.QueryString["Number"];
string strCode = strNumber.Substring(0,1);
this.Label1.Text = strCode.ToString();
Andrew FensterRank #983 · 2K reputationPosted Aug 24, 2010, 6:03 PM EDT
int x = strNumber.IndexOf("."); // Get the location of the decimal point.
if (x == -1) // -1 means there was no decimal point found.
Label1.Text = strNumber;
else
Label1.Text = strNumber.Substring(0, x); // Get all the characters to the left of the decimal point.
Brett3 reputationPosted Aug 25, 2010, 7:50 AM EDT