473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Input string not in correct format...

Everytime I run my code, it shows an error that the input string is
not in correct format.
Could anybody tell me what is wrong with my line of code?

str3 = Integer.Parse(dropBasis3.SelectedIndex - 1, 10) + ";"

Feb 19 '07 #1
6 3880
On Feb 19, 11:09 am, "Garg" <shivaniga...@gmail.comwrote:
Everytime I run my code, it shows an error that the input string is
not in correct format.
Could anybody tell me what is wrong with my line of code?

str3 = Integer.Parse(dropBasis3.SelectedIndex - 1, 10) + ";"
I suppose that dropBasis3.SelectedIndex - 1 is an integer?
Integer.Parse needs a string.

What does ", 10" means?

Feb 19 '07 #2

10 represents the system in which we want our integer answer.
So, here 10 stands for decimal system.
If we had wanted our answer in binary sytem, then instead of 10. it
would have been 2
Feb 19 '07 #3
On Feb 19, 11:42 am, "Garg" <shivaniga...@gmail.comwrote:
10 represents the system in which we want our integer answer.
So, here 10 stands for decimal system.
If we had wanted our answer in binary sytem, then instead of 10. it
would have been 2
well, ok, I didn't know it, thanks

Back to your problem - what do you want to parse from integer???

Maybe you wanted to have

dropBasis3.Items(dropBasis3.SelectedIndex - 1).ToString()

?

Feb 19 '07 #4
On Feb 19, 3:52 pm, "Alexey Smirnov" <alexey.smir...@gmail.comwrote:
On Feb 19, 11:42 am, "Garg" <shivaniga...@gmail.comwrote:
10 represents the system in which we want our integer answer.
So, here 10 stands for decimal system.
If we had wanted our answer in binary sytem, then instead of 10. it
would have been 2

well, ok, I didn't know it, thanks

Back to your problem - what do you want to parse from integer???

Maybe you wanted to have

dropBasis3.Items(dropBasis3.SelectedIndex - 1).ToString()

?
thats alrite..
I've removed that integer.parse function from there. I realised it
wan't needed at all there. so, no problems now in my code.

Feb 19 '07 #5
Hi Garg

This is not javascript. In .NET Integer.Parse(string, flags) flags parameter
has quite different meaning - it determines the styles permitted in numeric
string arguments that are passed to the Parse methods of the numeric base
type classes. Please read MSDN documentation before using a function/method.

Best regards
--
Milosz
"Garg" wrote:
>
10 represents the system in which we want our integer answer.
So, here 10 stands for decimal system.
If we had wanted our answer in binary sytem, then instead of 10. it
would have been 2
Feb 19 '07 #6
Garg,

dropBasis3.SelectedIndex is already a integer value. I quess you come from
javascript /vbscript programming (correct me if i'm wrong) you are trying to
execute equivalent code
var x = parseInt(whatever, 10).
Forget it.

vb.net:
dim str3 as string = Convert.ToString(dropBasis3.SelectedIndex - 1) & ";"
c#:
string str3 = Convert.ToString(dropBasis3.SelectedIndex - 1) + ";"

Or maybe if i didn't get you right, you're trying to parse drop down list
selected value:

vb.net:
Dim result As Integer
Dim str3 As String = IIf(Integer.TryParse(dropBasis3.SelectedValue ,
result), result, 0) & ";"
c#:
int result;
string str3 = int.TryParse(dropBasis3.SelectedValue, out result) ?
result.ToString() : "0";
str3 += ";";

hope this helps

--
Milosz
"Garg" wrote:
Everytime I run my code, it shows an error that the input string is
not in correct format.
Could anybody tell me what is wrong with my line of code?

str3 = Integer.Parse(dropBasis3.SelectedIndex - 1, 10) + ";"

Feb 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
im using asp.net, C# to enter data into a table in sql server...however im getting this error: Input string was not in a correct format. Description: An unhandled exception occurred during the...
0
by: lianfe_ravago | last post by:
Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the...
5
by: blackg | last post by:
Input string not in correct format -------------------------------------------------------------------------------- I am trying to view a picture from a table. I am getting this error Input string...
1
by: amitbadgi | last post by:
Welcome back amitbadgi | Logout | Faq Knowledge Discovery Keys COMPUTER PROGRAMMING, DATA MINING, STATISTICS, ARTIFICIAL INTELLIGENCE * Settings * Photos * Lists * MVPs * Forums * Blogs
1
by: amitbadgi | last post by:
I am gettign this error, while migration an app to asp.net Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 19: Dim enddate =...
0
by: hudhuhandhu | last post by:
have got an error which says Input string was not in a correct format. as follows.. Description: An unhandled exception occurred during the execution of the current web request. Please review the...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
0
by: sehguh | last post by:
Hiya Folks, I am Currently using windows xp. Also using Visual Web Developer 2005 and Microsoft Sql server 2005. The main page consists of an aspx page and a master page. The page also...
1
by: sehguh | last post by:
Hello folks I have recently been studying a book called "sams teach yourself asp.net 2.0 in24 hours by scott mitchell. I have reached page 614 but when i tried to run an asp page called...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.